Skip to content

use-ing an item from the current module causes unresolved use errors. #8640

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
brandonson opened this issue Aug 20, 2013 · 4 comments · Fixed by #26718
Closed

use-ing an item from the current module causes unresolved use errors. #8640

brandonson opened this issue Aug 20, 2013 · 4 comments · Fixed by #26718
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically

Comments

@brandonson
Copy link
Contributor

Something like this should really produce a better error message:

mod foo {                                                                                           
  extern mod extra;                                                                                 

  use foo::extra;                                                                                       
}

/////////////////////////////////
//The error:
//bug-testing.rs:4:6: 4:16 error: unresolved import
//bug-testing.rs:4   use foo::extra;
//                       ^~~~~~~~~~
//error: aborting due to previous error
//////////////////////////////////

Not sure whether current compiler state makes it difficult to identify this and other reasons for failed resolution, but if it's fairly simple better error messages would be great.

@huonw
Copy link
Member

huonw commented Nov 24, 2013

Triage: this appears to be a problem with directly re-importing an from the current module, e.g.

mod foo {
    use foo::bar;
    mod bar {}
}

fn main() {}

gives the same error pointing at use foo::bar. (Adjusting the issue title to reflect this.)

@huonw
Copy link
Member

huonw commented Nov 24, 2013

(For comparison, importing something with the same name from a different module is ok:

#[allow(unused_imports)];

mod foo {
    use baz::bar;
    mod bar {}
}
mod baz { pub mod bar {} }

fn main() {}

compiles without a problem.)

@treeman
Copy link
Contributor

treeman commented Aug 13, 2014

Still an issue.

$ rustc -v
rustc 0.12.0-pre (470dbef29 2014-07-25 09:31:10 +0000)
mod foo {
    use foo::bar;
    mod bar {}
}

fn main() {}

Gives error: unresolved import pointing at foo in use foo::bar.

#![allow(unused_imports)]

mod foo {
    use baz::bar;
    mod bar {}
}
mod baz { pub mod bar {} }

fn main() {}

Works. (Updated attribute syntax)

@mukilan
Copy link
Contributor

mukilan commented Dec 7, 2014

Both cases (use foo::bar and use baz::bar) now give import bar conflicts with existing submodule error.
I recently fixed the use foo::bar case as a part of the duplicate issue #19498. I'm not sure when the "use baz::bar" case was fixed.
Also see related issue #19609

nham pushed a commit to nham/rust that referenced this issue Jul 1, 2015
This doesn't add a test for the main problem in rust-lang#8640 since it seems that
was already fixed (including a test) in PR rust-lang#19522. This just adds a test
for a program mentioned in the comments that used to erroneously compile.

Closes rust-lang#8640.
bors added a commit that referenced this issue Jul 2, 2015
This doesn't add a test for the main problem in #8640 since it seems that
was already fixed (including a test) in PR #19522. This just adds a test
for a program mentioned in the comments that used to erroneously compile.

Closes #8640.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants