Handling of self and super in use and mod statements is inconsistent. Playpen:
use self; // error: `self` imports are only allowed within a { } list [E0429] (expected)
// error: unresolved import `self`. There is no `self` in the crate root [E0432]
mod super { // error: expected identifier, found keyword `super`
type Test = u32;
mod submodule {
use super; // error: a module named `super` has already been imported in this module [E0252]
use super::{self, Test}; // (^^^ apparently "already" means "on the next line"?)
}
use super; // (no error for this one?)
}
There are probably several (related) issues here.
- Inconsistent handling of keyword status for
self and super as module names: if we add a mod self { } to the above, we get the two "expected identifier, found keyword" errors we'd expect -- and no other output. It appears that mod self { } causes an immediate "aborting due to previous error", while mod super { } does not.
use super::{self, ...}; doesn't special-case the self keyword as a keyword like use foo::bar::{self, ...}; does.
use super; doesn't special-case the super keyword as a keyword.
use self; does do some special-casing so it can produce "error: self imports are only allowed within a { } list [E0429]", but it then continues by attempting to resolve self as an ident.
Handling of
selfandsuperinuseandmodstatements is inconsistent. Playpen:There are probably several (related) issues here.
selfandsuperas module names: if we add amod self { }to the above, we get the two "expected identifier, found keyword" errors we'd expect -- and no other output. It appears thatmod self { }causes an immediate "aborting due to previous error", whilemod super { }does not.use super::{self, ...};doesn't special-case theselfkeyword as a keyword likeuse foo::bar::{self, ...};does.use super;doesn't special-case thesuperkeyword as a keyword.use self;does do some special-casing so it can produce "error:selfimports are only allowed within a { } list [E0429]", but it then continues by attempting to resolveselfas an ident.