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

Using super and self in middle of path gives unhelpful error message #45229

Closed
Havvy opened this issue Oct 12, 2017 · 0 comments
Closed

Using super and self in middle of path gives unhelpful error message #45229

Havvy opened this issue Oct 12, 2017 · 0 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution WG-diagnostics Working group: Diagnostics

Comments

@Havvy
Copy link
Contributor

Havvy commented Oct 12, 2017

use a_module::self::AnItem as Test1;
use a_module::super::a_module::AnItem as Test2;

mod a_module {
    struct AnItem;
}

fn main () {}
Current Error Message
Compiling playground v0.0.1 (file:///playground)
error[E0432]: unresolved import `a_module::self`
 --> src/main.rs:1:15
  |
1 | use a_module::self::AnItem as Test1;
  |               ^^^^ Could not find `self` in `a_module`

error[E0432]: unresolved import `a_module::super`
 --> src/main.rs:2:15
  |
2 | use a_module::super::a_module::AnItem as Test2;
  |               ^^^^^ Could not find `super` in `a_module`

warning: unused import: `a_module::self::AnItem as Test1`
 --> src/main.rs:1:5
  |
1 | use a_module::self::AnItem as Test1;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused import: `a_module::super::a_module::AnItem as Test2`
 --> src/main.rs:2:5
  |
2 | use a_module::super::a_module::AnItem as Test2;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Ignoring the warnings (they're good warnings), the errors should state that `self` and `super` are only allowed before non-`self` and `super` path components.
@petrochenkov petrochenkov added A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution labels Oct 12, 2017
@petrochenkov petrochenkov self-assigned this Oct 12, 2017
@estebank estebank added E-needs-mentor WG-diagnostics Working group: Diagnostics labels Oct 12, 2017
bors added a commit that referenced this issue Nov 21, 2017
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 resolution WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

3 participants