Skip to content

Absolute paths in enum variant names cause "a variety of fun errors" #5269

Closed
@brendanzab

Description

@brendanzab
enum ABC {
    A, B, C
}

mod test {
    fn test(abc: ::ABC) {
        match abc {
            ::A => {}
            ::B => {}
            ::C => {}
        }
    }
}

fn main() {}
$ rustc enum-abc.rs
enum-abc.rs:6:17: 6:22 error: use of undeclared type name `ABC`
enum-abc.rs:6     fn test(abc: ::ABC) {
                               ^~~~~
enum-abc.rs:8:12: 8:15 error: unresolved name: `A`.
enum-abc.rs:8             ::A => {}
                          ^~~
enum-abc.rs:9:12: 9:15 error: unresolved name: `B`.
enum-abc.rs:9             ::B => {}
                          ^~~
enum-abc.rs:10:12: 10:15 error: unresolved name: `C`.
enum-abc.rs:10             ::C => {}
                           ^~~
error: aborting due to 4 previous errors

pub enum ABC {
    A, B, C
}

mod test {
    fn test(abc: ::ABC) {
        match abc {
            ::A => {}
            ::B => {}
            ::C => {}
        }
    }
}

fn main() {}
$ rustc enum-abc.rs
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues

enum ABC {
    A(()), B, C
}

mod test {
    fn test(abc: ::ABC) {
        match abc {
            ::A(_) => {}
            ::B    => {}
            ::C    => {}
        }
    }
}

fn main() {}
$ rustc enum-abc.rs
enum-abc.rs:8:16: 8:17 error: unexpected token: `_`
enum-abc.rs:8             ::A(_) => {}
                              ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions