Skip to content

'Unsupported constant expr' when matching on tuple-struct constants #6533

Closed
@brendanzab

Description

@brendanzab

edited because it no longer ICEs.

pub mod glfw {
    pub struct InputState(uint);

    pub static RELEASE  : InputState = InputState(0);
    pub static PRESS    : InputState = InputState(1);
    pub static REPEAT   : InputState = InputState(2);
}

fn action_to_str(state: glfw::InputState) -> ~str {
    use glfw::{RELEASE, PRESS, REPEAT};
    match state {
        RELEASE => { ~"Released" }
        PRESS   => { ~"Pressed"  }
        REPEAT  => { ~"Repeated" }
        _       => { ~"Unknown"  }
    }
}

fn main() {}

Error:

ice.rs:4:40: 4:53 error: unsupported constant expr
ice.rs:4     pub static RELEASE  : InputState = InputState(0);
                                                ^~~~~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions