Closed
Description
#![feature(nonzero, const_fn)]
extern crate core;
mod a {
use core::nonzero::NonZero;
#[derive(Eq, PartialEq)]
pub struct Foo {
bar: NonZero<u64>, // Private
}
pub const FOO: Foo = Foo {
bar: unsafe { NonZero::new(2) },
};
}
fn main() {
assert!(a::FOO == a::FOO);
assert!(match a::FOO {
a::FOO => true,
_ => false,
});
}
rustc 1.19.0-nightly (d3abc80 2017-05-09)
error[E0080]: constant evaluation error
|
note: for pattern here
--> a.rs:21:9
|
21 | a::FOO => true,
| ^^^^^^
error: aborting due to previous error
The error message doesn’t say what’s wrong with this pattern. Based on code in src/librustc/middle/const_val.rs
it looks like more info should be printed, with ConstEvalErr::description
.
CC @eddyb