Skip to content

Matching on an enum shouldn't require full scoping inside the match #421

@rust-highfive

Description

@rust-highfive

Issue by mdinger
Friday Aug 22, 2014 at 18:16 GMT

For earlier discussion, see rust-lang/rust#16681

This issue was labelled with: in the Rust repository


// main.rs
extern crate really;

fn main() {
    let my_enum = really::long::A;

    // This match works with full scoping
    match my_enum {
        really::long::A => {},
        really::long::B => {},
        really::long::C => {},
        really::long::D => {},
        really::long::E => {},
        really::long::F => {},
        really::long::G => {},
    }

    // This doesn't because the scope is missing but the scope
    // doesn't add anything because it's matching variants of an
    // already defined enum.  This should work.
    match my_enum {
        A => {},
        B => {},
        C => {},
        D => {},
        E => {},
        F => {},
        G => {},
    }
}
// lib.rs
pub mod long;
// long.rs
pub enum Enumeration {
    A,
    B,
    C,
    D,
    E,
    F,
    G,
}

I was trying to de-glob libsyntax (rust-lang/rust#11983) but this is a real nuisance there. The enums are much much bigger than this.

I hope this is clear. Let me know if it isn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions