Description
pub mod a {
use super as root;
}
// error[E0432]: unresolved import `super`
// --> <anon>:3:9
// |
// 3 | use super as root;
// | ^^^^^^^^^^^^^ no `super` in the root
super
is a keyword. There can’t ever be anything named super
in the root.
fn main() {
let super = 2;
}
// error[E0531]: unresolved unit struct/variant or constant `super`
// --> <anon>:2:9
// |
// 2 | let super = 2;
// | ^^^^^
Similarly, rustc should be reporting that super
is a keyword and cannot be used as an identifier. I suspect the error arises from the fact that super is parsed to be the whole pattern here. Example below results in the same diagnostic, but may be easier to understand why the error is what it is:
fn main() {
match 2 {
super => {}
}
}
// same error
Notably you cannot have something like this either:
mod a {}
struct a; // a is already defined
fn main() {
let ::a = 2;
}
So in general this error message could be improved to say that super
is a module (?) and cannot be used in a pattern this way.
We over at the #rust-lang have ideas how a use super as root
could be used to make life easier (@solson said they’ll write an RFC). In other cases resolve should probably just stop accepting super
by itself and/or just resolve it to a module.