Skip to content

Can't bring nested mod into scope with use foo::foo #5130

Closed

Description

@ben0x539

The use foo::foo; line seems to do nothing at all, the reference to foo inside main still seems to resolve to the outer foo.

    mod foo {
        pub mod foo {
            pub fn f() {}
        }
    }

    use foo::foo;

    fn main() {
        foo::f();
    }
hw.rs:10:4: 10:10 error: unresolved name: foo::f
hw.rs:10     foo::f();
             ^~~~~~

Should the use item just be illegal if it collides with an existing name? This issue confused me for quite a while with the rust-sdl package's sdl crate that contains an sdl mod.

Activity

  1. catamorphism commented on Apr 25, 2013

    @catamorphism
    Contributor

    Seems non-critical for 0.7. Nominating for milestone #1 (well-defined).

  2. graydon commented on May 2, 2013

    @graydon
    Contributor

    This is an "expected no-shadowing, got shadowing" case. it now rejects at parse level because the use things must come first. (This is actually the case that rule was introduced to handle).

  3. added a commit that references this issue on May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions