Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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/path resolution done by `rustc_resolve` specifically 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/path resolution done by `rustc_resolve` specifically 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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

3 participants