You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uninformative error on type mismatch in enum value constexpr #13534
$ rustc -v
rustc 0.11-pre (cee9a83 2014-04-11 15:54:46 -0700)
host: x86_64-unknown-linux-gnu
$ rustc --crate-type lib foo.rs
foo.rs:4:11: 4:27 error: expected constant: bad operands for binary
foo.rs:4 Bar = (1u & 0xff) << 1,
^~~~~~~~~~~~~~~~
error: aborting due to previous error
Dropping the shift gives a more informative error:
foo.rs:4:11: 4:22 error: expected constant: can't do this op on a uint and int
foo.rs:4 Bar = (1u & 0xff), // << 1,
^~~~~~~~~~~
error: aborting due to previous error
The fix is to write 0xffu, but the first error message was no help in finding this within a more complex expression inside a macro.
By contrast, this compiles fine:
static x: uint = (1u & 0xff) << 1;
and this
static x: uint = (1u & 0xffi) << 1;
gives a more conventional type error
foo.rs:1:24: 1:29 error: mismatched types: expected `uint` but found `int` (expected uint but found int)
foo.rs:1 static x: uint = (1u & 0xffi) << 1;
tmp.rs:2:12: 2:25 error: constant evaluation error: can't do this op on a usize and isize [E0080]
tmp.rs:2 Bar = (1usize & 0xff) << 1,
^~~~~~~~~~~~~
tmp.rs:2:12: 2:25 help: run `rustc --explain E0080` to see a detailed explanation
error: aborting due to previous error
Activity
Stebalien commentedon Aug 11, 2015
The error now reads:
So this is probably fixed.
steveklabnik commentedon Nov 5, 2015
Yup! Same error today, seems fine.
Auto merge of rust-lang#13534 - GnomedDev:fix-large-stack-arrays-nest…