Skip to content

Resolve needs a better error message for some imports #7584

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

Closed
emberian opened this issue Jul 4, 2013 · 5 comments
Closed

Resolve needs a better error message for some imports #7584

emberian opened this issue Jul 4, 2013 · 5 comments
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@emberian
Copy link
Member

emberian commented Jul 4, 2013

All imports are relative to the root of the crate, not the current mod. This is counterintuitive and the error messages are rather unhelpful. For example, a use foo; should, when resolve fails, look in self to see if there is a foo and in the error message suggest using use self::foo.

Part of #7379.

@emberian
Copy link
Member Author

emberian commented Jul 4, 2013

This interacts especially poorly with extern mod's, from #7583:

mod a {
    extern mod extra;
    use extra::json;
}

fn main() {}

generates

/tmp/b.rc:4:8: 4:13 error: unresolved import. maybe a missing `extern mod extra`?
/tmp/b.rc:4     use extra::json;
                    ^~~~~
/tmp/b.rc:4:8: 4:19 error: failed to resolve import `extra::json`
/tmp/b.rc:4     use extra::json;
                    ^~~~~~~~~~~
error: aborting due to 2 previous errors

@catamorphism
Copy link
Contributor

Triage bump. Agreed it should be better, but not a release blocker.

@mrshu
Copy link
Contributor

mrshu commented Feb 6, 2014

I would like to try to tackle this one by at least providing a better explanation of what is going on.

I was able to figure out that it will be necessary to alter librustc/middle/resolve.rs but I am not sure how to look in self as @cmr pointed out. Could please someone help me out with this? Thanks.

@treeman
Copy link
Contributor

treeman commented Aug 13, 2014

Same as #8640.

@alexcrichton
Copy link
Member

This I believe was actually closed in 207bfee

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 8, 2021
…effen

Extend unnecessary_unwrap to look for expect in addition to unwrap

changelog: Extend ``[`unnecessary_unwrap`]`` to also check for `Option::expect` and `Result::expect`. Also give code suggestions in some cases.

Fixes rust-lang#7581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

5 participants