Skip to content

Match condition with a global path to singleton enum constructors just creates a new variable #15774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
huonw opened this issue Jul 18, 2014 · 2 comments · Fixed by #15862
Closed
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically

Comments

@huonw
Copy link
Member

huonw commented Jul 18, 2014

enum Foo { A }
mod bar {
    pub fn normal(x: ::Foo) {
        use A;
        match x {
            A => {}
        }
    }
    pub fn wrong(x: ::Foo) {
        match x {
            ::A => {}
        }
    }
}

fn main() { bar::normal(A); bar::wrong(A); }
global-path-match.rs:11:13: 11:16 warning: unused variable: `A`, #[warn(unused_variable)] on by default
global-path-match.rs:11             ::A => {}
                                    ^~~
global-path-match.rs:11:13: 11:16 warning: variable names should start with a lowercase character, #[warn(uppercase_variables)] on by default
global-path-match.rs:11             ::A => {}
                                    ^~~

That is, it's not obeying the global part of the path and instead just creating a variable with the name A.

@alexcrichton
Copy link
Member

cc @jakub-

@huonw
Copy link
Member Author

huonw commented Jul 18, 2014

Oh, and moving the use A out of normal to mod bar { use A; ... makes wrong compile without warning, so I guess the global boolean is just being ignored somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants