Update tests
This commit is contained in:
parent
d2f363ba89
commit
8c53d54b98
7 changed files with 31 additions and 27 deletions
|
@ -81,7 +81,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
|
||||||
let value = match self.tcx.const_eval(self.param_env.and(cid)) {
|
let value = match self.tcx.const_eval(self.param_env.and(cid)) {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.report(self.tcx, span, "const prop");
|
err.report(self.tcx, span, "constant propagated");
|
||||||
return None;
|
return None;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,6 +14,9 @@ pub const A: i8 = -std::i8::MIN;
|
||||||
//~^ ERROR E0080
|
//~^ ERROR E0080
|
||||||
//~| ERROR const_err
|
//~| ERROR const_err
|
||||||
//~| ERROR const_err
|
//~| ERROR const_err
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| ERROR E0080
|
//~| ERROR E0080
|
||||||
pub const B: i8 = A;
|
pub const B: i8 = A;
|
||||||
//~^ ERROR E0080
|
//~^ ERROR E0080
|
||||||
|
|
|
@ -23,6 +23,7 @@ fn black_box<T>(_: T) {
|
||||||
// Make sure that the two uses get two errors.
|
// Make sure that the two uses get two errors.
|
||||||
const FOO: u8 = [5u8][1];
|
const FOO: u8 = [5u8][1];
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| index out of bounds: the len is 1 but the index is 1
|
//~| index out of bounds: the len is 1 but the index is 1
|
||||||
//~| ERROR E0080
|
//~| ERROR E0080
|
||||||
|
|
||||||
|
|
|
@ -23,64 +23,64 @@ use std::{u8, u16, u32, u64, usize};
|
||||||
|
|
||||||
const VALS_I8: (i8,) =
|
const VALS_I8: (i8,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to subtract with overflow
|
//~| attempt to subtract with overflow
|
||||||
(
|
(
|
||||||
i8::MIN - 1,
|
i8::MIN - 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_I16: (i16,) =
|
const VALS_I16: (i16,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to subtract with overflow
|
//~| attempt to subtract with overflow
|
||||||
(
|
(
|
||||||
i16::MIN - 1,
|
i16::MIN - 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_I32: (i32,) =
|
const VALS_I32: (i32,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to subtract with overflow
|
//~| attempt to subtract with overflow
|
||||||
(
|
(
|
||||||
i32::MIN - 1,
|
i32::MIN - 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_I64: (i64,) =
|
const VALS_I64: (i64,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to subtract with overflow
|
//~| attempt to subtract with overflow
|
||||||
(
|
(
|
||||||
i64::MIN - 1,
|
i64::MIN - 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U8: (u8,) =
|
const VALS_U8: (u8,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to subtract with overflow
|
//~| attempt to subtract with overflow
|
||||||
(
|
(
|
||||||
u8::MIN - 1,
|
u8::MIN - 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U16: (u16,) = (
|
const VALS_U16: (u16,) = (
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to subtract with overflow
|
//~| attempt to subtract with overflow
|
||||||
u16::MIN - 1,
|
u16::MIN - 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U32: (u32,) = (
|
const VALS_U32: (u32,) = (
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to subtract with overflow
|
//~| attempt to subtract with overflow
|
||||||
u32::MIN - 1,
|
u32::MIN - 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U64: (u64,) =
|
const VALS_U64: (u64,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to subtract with overflow
|
//~| attempt to subtract with overflow
|
||||||
(
|
(
|
||||||
u64::MIN - 1,
|
u64::MIN - 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -23,64 +23,64 @@ use std::{u8, u16, u32, u64, usize};
|
||||||
|
|
||||||
const VALS_I8: (i8,) =
|
const VALS_I8: (i8,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to add with overflow
|
//~| attempt to add with overflow
|
||||||
(
|
(
|
||||||
i8::MAX + 1,
|
i8::MAX + 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_I16: (i16,) =
|
const VALS_I16: (i16,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to add with overflow
|
//~| attempt to add with overflow
|
||||||
(
|
(
|
||||||
i16::MAX + 1,
|
i16::MAX + 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_I32: (i32,) =
|
const VALS_I32: (i32,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to add with overflow
|
//~| attempt to add with overflow
|
||||||
(
|
(
|
||||||
i32::MAX + 1,
|
i32::MAX + 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_I64: (i64,) =
|
const VALS_I64: (i64,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to add with overflow
|
//~| attempt to add with overflow
|
||||||
(
|
(
|
||||||
i64::MAX + 1,
|
i64::MAX + 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U8: (u8,) =
|
const VALS_U8: (u8,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to add with overflow
|
//~| attempt to add with overflow
|
||||||
(
|
(
|
||||||
u8::MAX + 1,
|
u8::MAX + 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U16: (u16,) = (
|
const VALS_U16: (u16,) = (
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to add with overflow
|
//~| attempt to add with overflow
|
||||||
u16::MAX + 1,
|
u16::MAX + 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U32: (u32,) = (
|
const VALS_U32: (u32,) = (
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to add with overflow
|
//~| attempt to add with overflow
|
||||||
u32::MAX + 1,
|
u32::MAX + 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U64: (u64,) =
|
const VALS_U64: (u64,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to add with overflow
|
//~| attempt to add with overflow
|
||||||
(
|
(
|
||||||
u64::MAX + 1,
|
u64::MAX + 1,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -23,64 +23,64 @@ use std::{u8, u16, u32, u64, usize};
|
||||||
|
|
||||||
const VALS_I8: (i8,) =
|
const VALS_I8: (i8,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to multiply with overflow
|
//~| attempt to multiply with overflow
|
||||||
(
|
(
|
||||||
i8::MIN * 2,
|
i8::MIN * 2,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_I16: (i16,) =
|
const VALS_I16: (i16,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to multiply with overflow
|
//~| attempt to multiply with overflow
|
||||||
(
|
(
|
||||||
i16::MIN * 2,
|
i16::MIN * 2,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_I32: (i32,) =
|
const VALS_I32: (i32,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to multiply with overflow
|
//~| attempt to multiply with overflow
|
||||||
(
|
(
|
||||||
i32::MIN * 2,
|
i32::MIN * 2,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_I64: (i64,) =
|
const VALS_I64: (i64,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to multiply with overflow
|
//~| attempt to multiply with overflow
|
||||||
(
|
(
|
||||||
i64::MIN * 2,
|
i64::MIN * 2,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U8: (u8,) =
|
const VALS_U8: (u8,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to multiply with overflow
|
//~| attempt to multiply with overflow
|
||||||
(
|
(
|
||||||
u8::MAX * 2,
|
u8::MAX * 2,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U16: (u16,) = (
|
const VALS_U16: (u16,) = (
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to multiply with overflow
|
//~| attempt to multiply with overflow
|
||||||
u16::MAX * 2,
|
u16::MAX * 2,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U32: (u32,) = (
|
const VALS_U32: (u32,) = (
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to multiply with overflow
|
//~| attempt to multiply with overflow
|
||||||
u32::MAX * 2,
|
u32::MAX * 2,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const VALS_U64: (u64,) =
|
const VALS_U64: (u64,) =
|
||||||
//~^ ERROR constant evaluation error
|
//~^ ERROR constant evaluation error
|
||||||
|
//~| ERROR constant evaluation error
|
||||||
//~| attempt to multiply with overflow
|
//~| attempt to multiply with overflow
|
||||||
(
|
(
|
||||||
u64::MAX * 2,
|
u64::MAX * 2,
|
||||||
//~^ ERROR constant evaluation error
|
|
||||||
);
|
);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
//https://github.com/rust-lang/rust/issues/31364
|
//https://github.com/rust-lang/rust/issues/31364
|
||||||
|
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
const fn a() -> usize { b() } //~ ERROR constant evaluation error
|
const fn a() -> usize { b() }
|
||||||
const fn b() -> usize { a() }
|
const fn b() -> usize { a() }
|
||||||
const ARR: [i32; a()] = [5; 6];
|
const ARR: [i32; a()] = [5; 6]; //~ ERROR constant evaluation error
|
||||||
|
|
||||||
fn main(){}
|
fn main(){}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue