Skip to content
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

Uniformative error message when missing a "self" while importing a module #31573

Closed
julienw opened this issue Feb 11, 2016 · 4 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@julienw
Copy link

julienw commented Feb 11, 2016

Exemple code:

mod foo {
  mod hello {
    pub enum world {}
  }
  use hello::world;
}

fn main() {
}

Error is:

<anon>:6:7: 6:12 error: unresolved import `hello::world`. Maybe a missing `extern crate hello`? [E0432]
<anon>:6   use hello::world;
               ^~~~~
<anon>:6:7: 6:12 help: see the detailed explanation for E0432
error: aborting due to previous error
playpen: application terminated with error code 101

The compiler should detect that "self" is missing.

Note this is an error I do all the time as a beginner.

@SimonSapin
Copy link
Contributor

Even without doing an analysis of what could have likely been intended this error message could mention that paths in use are absolute by default, unless they start with self:: or super::.

@michaelwoerister michaelwoerister added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 11, 2016
@frewsxcv
Copy link
Member

Ran into this a few days ago, would love to the messaging here improved 👍

@birkenfeld
Copy link
Contributor

The linked PR adds the information to the long diagnostics, at least.

Note that if you just have an use module; then the error message is markedly different:

error: unresolved import `modname`. There is no `modname` in the crate root [E0432]

I wonder if some consolidation would be in order.

birkenfeld added a commit to birkenfeld/rust that referenced this issue May 2, 2016
This is curiously missing from both the short message and this
long diagnostic.

Refs rust-lang#31573 (not sure if it should be considered "fixed" as the
short message still only refers to extern crates).
Manishearth added a commit to Manishearth/rust that referenced this issue May 2, 2016
diagnostics for E0432: imports are relative to crate root

This is curiously missing from both the short message and this long diagnostic.

Refs rust-lang#31573 (not sure if it should be considered "fixed" as the short message still only refers to extern crates).
Manishearth added a commit to Manishearth/rust that referenced this issue May 3, 2016
diagnostics for E0432: imports are relative to crate root

This is curiously missing from both the short message and this long diagnostic.

Refs rust-lang#31573 (not sure if it should be considered "fixed" as the short message still only refers to extern crates).
@jseyfried
Copy link
Contributor

Fixed in #36289.

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
Projects
None yet
Development

No branches or pull requests

6 participants