Skip to content

super used in the middle of path is incorrectly accepted #152997

@mu001999

Description

@mu001999

The first import in the following example should fail (play):

pub mod x {
    pub use crate::x::super::{self as crate1}; // OK but should ERROR
    pub use crate::x::self::super::{self as crate2}; //~ ERROR `self` in paths can only be used in start position

    pub fn foo() {}
}

fn main() {
    x::crate1::x::foo();
    x::crate2::x::foo();
    
    crate::x::super::x::foo(); //~ ERROR `super` in paths can only be used in start position
    crate::x::self::super::x::foo(); //~ ERROR `self` in paths can only be used in start position
}

Version

Build using the Nightly version: 1.95.0-nightly
(2026-02-21 5fb2ff8)

Metadata

Metadata

Assignees

Labels

A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamregression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions