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
$ 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;
The text was updated successfully, but these errors were encountered:
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
…ed-item, r=flip1995
Fix large_stack_arrays triggering when nesting const items
Fixesrust-lang#13529.
r? `@flip1995`
changelog: [`large_stack_arrays`]: No longer triggers in static/const context when using nested items
Dropping the shift gives a more informative 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:
and this
gives a more conventional type error
The text was updated successfully, but these errors were encountered: