Fallout from changes for overflow-checking during constant evaluation.
This commit is contained in:
parent
6808e414c7
commit
8d54ea3ec9
6 changed files with 17 additions and 7 deletions
|
|
@ -8,9 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Note: This test is checking that we forbid a coding pattern that
|
||||
// Issue #5873 explicitly wants to allow.
|
||||
|
||||
enum State { ST_NULL, ST_WHITESPACE }
|
||||
|
||||
fn main() {
|
||||
[State::ST_NULL; (State::ST_WHITESPACE as usize)];
|
||||
//~^ ERROR expected constant integer for repeat count, found non-constant expression
|
||||
//~^ ERROR expected constant integer for repeat count, but non-constant path
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
fn main() {
|
||||
fn bar(n: usize) {
|
||||
let _x = [0; n]; //~ ERROR expected constant integer for repeat count, found variable
|
||||
let _x = [0; n];
|
||||
//~^ ERROR expected constant integer for repeat count, found variable
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,16 @@
|
|||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(core)]
|
||||
|
||||
// Catch mistakes in the overflowing literals lint.
|
||||
#![deny(overflowing_literals)]
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(0xffffffff, (-1 as u32));
|
||||
assert_eq!(4294967295, (-1 as u32));
|
||||
assert_eq!(0xffffffffffffffff, (-1 as u64));
|
||||
assert_eq!(18446744073709551615, (-1 as u64));
|
||||
|
||||
assert_eq!(-2147483648 - 1, 2147483647);
|
||||
assert_eq!((-2147483648).wrapping_sub(1), 2147483647);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ static CLs: Es = Es::Ls;
|
|||
static CHs: Es = Es::Hs;
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!((Eu::Hu as u8) + 1, Eu::Lu as u8);
|
||||
assert_eq!((Es::Hs as i8) + 1, Es::Ls as i8);
|
||||
assert_eq!((Eu::Hu as u8).wrapping_add(1), Eu::Lu as u8);
|
||||
assert_eq!((Es::Hs as i8).wrapping_add(1), Es::Ls as i8);
|
||||
assert_eq!(CLu as u8, Eu::Lu as u8);
|
||||
assert_eq!(CHu as u8, Eu::Hu as u8);
|
||||
assert_eq!(CLs as i8, Es::Ls as i8);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue