Skip to content

Module shadowing is prohibited in RFC but allowed by rustc #111339

Closed
@obi1kenobi

Description

@obi1kenobi

I tried this code:

mod a {
    pub mod collide {
        pub struct Foo {}   
    }
}

pub use a::*;

pub mod collide {
    pub struct Bar {}
}

playground

I expected to see this happen: compilation error, since RFC 116 seems to explicitly prohibit shadowing modules.

Instead, this happened: compiles successfully and the collide module is shadowed, playground.

Related to #111336 which looks at other glob shadowing problems.

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (39c6804b9 2023-04-19)
binary: rustc
commit-hash: 39c6804b92aa202369e402525cee329556bc1db0
commit-date: 2023-04-19
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Also tested on Nightly version: 1.71.0-nightly (2023-05-07 c4190f2d3a46a59f435f) via the playground.

If RFC 116 has been superseded or withdrawn, I'm sorry — after some digging, I wasn't able to find any information to that effect, but perhaps I wasn't looking in the right places.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions