Skip to content

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

Closed
@huonw

Description

@huonw
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.

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