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

Constants behave differently depending on the way they're initialized. #28315

Closed
tbu- opened this issue Sep 9, 2015 · 1 comment
Closed

Constants behave differently depending on the way they're initialized. #28315

tbu- opened this issue Sep 9, 2015 · 1 comment

Comments

@tbu-
Copy link
Contributor

tbu- commented Sep 9, 2015

I can't match using a constant that was initialized using a byte string literal:

const ARRAY1: [u8; 0] = [];
const ARRAY2: [u8; 0] = *b"";

fn main() {
    match [] {
        ARRAY1 => {}
        ARRAY2 => {}
    }
}

This gets an error:

a.rs:2:25: 2:29 error: constant evaluation error: unsupported constant expr
a.rs:2 const ARRAY2: [u8; 0] = *b"";
                               ^~~~
a.rs:7:9: 7:15 note: in pattern here
a.rs:7         ARRAY2 => {}
               ^~~~~~
a.rs:2:25: 2:29 error: unsupported constant expr
a.rs:2 const ARRAY2: [u8; 0] = *b"";
                               ^~~~
@tbu-
Copy link
Contributor Author

tbu- commented Sep 19, 2015

It seems this is a duplicate of #25574.

@tbu- tbu- closed this as completed Sep 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant