-
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 use self::Thing::OtherThing
when using use Thing::OtherThing
#34191
Comments
use self::Thing
when using use Thing::OtherThing
use self::Thing::OtherThing
when using use Thing::OtherThing
cc me |
I'd like to work on this. I'm thinking: if we detect that adding "self" to the import resolves it, then a help message suggesting that is added. Otherwise, we add a help message that suggests |
@euclio Yeah, that makes sense -- I think that's a good idea. I would check whether prefixing |
resolve: Suggest `use self` when import resolves Improves errors messages by replacing "Maybe a missing `extern crate`" messages with "Did you mean `self::...`" when the `self` import would succeed. Fixes #34191. Thank you for the help @jseyfried!
This frequently happens for code like this:
Since this will compile when putting
m
s contents into the main module, this can be quite confusing (for example when refactoring some code into it's own module).Currently, this yields
error: unresolved import
MyEnum::*. Maybe a missing
extern crate MyEnum?
. When this case is detected, theMaybe a missing
extern crate MyEnum?
probably shouldn't be printed.The text was updated successfully, but these errors were encountered: