-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-langRelevant to the language teamRelevant to the language team
Description
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
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.
zroug
Metadata
Metadata
Assignees
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-langRelevant to the language teamRelevant to the language team