-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest removing self
import when not in a list
#63741
Comments
@petrochenkov Would it simplify or complicate things if we simply allowed this instead of rejecting it? |
~Simplify. |
Might be worth doing that in that case. (Although |
It needs some amount design work though (not large). The idea is to treat Also cc #48067 (path concatenation in macros). |
Visited in compiler triage. I think this is medium priority, clearly, but I am guessing that @Centril intended the nomination for the lang team. Wearing my lang team hat, I think I'd expect this to compile, but I don't have strong opinions about it. |
We discussed this in the lang team meeting last week. We decided that there were some reasons to tread carefully here: in particular, we didn't really want to admit the possibility of "non-canonical" paths like So the conclusion was "probably better to just leave it alone for now" from a language perspective. If we were to accept
|
In addition to a suggestion, the compiler could have better error recovery. Currently, the following produces errors on both the first and second line; it should only error on the first line: use std::mem; // `self` imports are only allowed within a { } list
fn main() { mem::drop(42); } // use of undeclared type or module `mem` |
@rustbot claim |
Suggest fixes and add error recovery for `use foo::self` Fixes rust-lang#63741. I have implemented 2 suggestions on how to fix a `use foo::self` import, however I feel like showing them both might be too verbose. Additionally, I have also implemented error recovery as [menitoned](rust-lang#63741 (comment)) by @comex. I believe r? @estebank deals with diagnostics.
we should offer the suggestion to remove
::self
, as this is likely what the user intended.This issue has been assigned to @mibac138 via this comment.
The text was updated successfully, but these errors were encountered: