Skip to content
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

error message misleading if expression unsupported in match #13626

Closed
nwin opened this issue Apr 19, 2014 · 1 comment
Closed

error message misleading if expression unsupported in match #13626

nwin opened this issue Apr 19, 2014 · 1 comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR)

Comments

@nwin
Copy link
Contributor

nwin commented Apr 19, 2014

When compiling

static val: [u8, ..1] = [0];

fn main() {
    match [1] {
        val => (),
        _ => ()
    }
}

The error message

$ rustc errormsg.rs 
errormsg.rs:1:25: 1:28 error: unsupported constant expr
errormsg.rs:1 static val: [u8, ..1] = [0];
                                      ^~~

points towards the definition of the constant and not the match statement which is misleading because the definition of the static value is perfectly fine but not its usage inside the match.

I am using rust 0.10.

@ben0x539
Copy link
Contributor

Came here because of http://chrismorgan.info/blog/teepee-design-status-line-take-two.html (the #3 section), would be neat if this could actually be supported.

bors added a commit that referenced this issue Jul 19, 2014
This is accomplished by rewriting static expressions into equivalent patterns.
This way, patterns referencing static variables can both participate
in exhaustiveness analysis as well as be compiled down into the appropriate
branch of the decision trees that match expressions are codegened to.

Fixes #6533.
Fixes #13626.
Fixes #13731.
Fixes #14576.
Fixes #15393.
@bors bors closed this as completed in fba1194 Jul 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants