diff options
Diffstat (limited to 'src/test')
25 files changed, 104 insertions, 121 deletions
diff --git a/src/test/compile-fail/E0306.rs b/src/test/compile-fail/E0306.rs deleted file mode 100644 index 9ffaef7472b..00000000000 --- a/src/test/compile-fail/E0306.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -const A: [u32; "hello"] = []; -//~^ ERROR expected `usize` for array length, found string literal [E0306] -//~| NOTE expected `usize` - -const B: [u32; true] = []; -//~^ ERROR expected `usize` for array length, found boolean [E0306] -//~| NOTE expected `usize` - -const C: [u32; 0.0] = []; -//~^ ERROR expected `usize` for array length, found float [E0306] -//~| NOTE expected `usize` - -fn main() { -} diff --git a/src/test/compile-fail/associated-const-array-len.rs b/src/test/compile-fail/associated-const-array-len.rs index 0239986f5ad..7f77ae2ec1f 100644 --- a/src/test/compile-fail/associated-const-array-len.rs +++ b/src/test/compile-fail/associated-const-array-len.rs @@ -14,7 +14,8 @@ trait Foo { const ID: usize; } -const X: [i32; <i32 as Foo>::ID] = [0, 1, 2]; //~ ERROR E0080 +const X: [i32; <i32 as Foo>::ID] = [0, 1, 2]; +//~^ ERROR the trait bound `i32: Foo` is not satisfied fn main() { assert_eq!(1, X); diff --git a/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs b/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs index 7c3f7a1d574..7fd9605ef2c 100644 --- a/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs +++ b/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs @@ -27,8 +27,6 @@ impl Foo for Def { pub fn test<A: Foo, B: Foo>() { let _array = [4; <A as Foo>::Y]; //~^ ERROR cannot use an outer type parameter in this context [E0402] - //~| ERROR constant evaluation error [E0080] - //~| non-constant path in constant } fn main() { diff --git a/src/test/compile-fail/associated-const-type-parameter-arrays.rs b/src/test/compile-fail/associated-const-type-parameter-arrays.rs index dcf87d5f0fc..71c7a3965ec 100644 --- a/src/test/compile-fail/associated-const-type-parameter-arrays.rs +++ b/src/test/compile-fail/associated-const-type-parameter-arrays.rs @@ -27,8 +27,6 @@ impl Foo for Def { pub fn test<A: Foo, B: Foo>() { let _array: [u32; <A as Foo>::Y]; //~^ ERROR cannot use an outer type parameter in this context [E0402] - //~| ERROR constant evaluation error [E0080] - //~| non-constant path in constant } fn main() { diff --git a/src/test/compile-fail/const-array-oob.rs b/src/test/compile-fail/const-array-oob.rs index b980bc02c85..108b7948dfc 100644 --- a/src/test/compile-fail/const-array-oob.rs +++ b/src/test/compile-fail/const-array-oob.rs @@ -12,8 +12,8 @@ #![feature(const_indexing)] -const FOO: [u32; 3] = [1, 2, 3]; -const BAR: u32 = FOO[5]; // no error, because the error below occurs before regular const eval +const FOO: [usize; 3] = [1, 2, 3]; +const BAR: usize = FOO[5]; // no error, because the error below occurs before regular const eval const BLUB: [u32; FOO[4]] = [5, 6]; //~^ ERROR constant evaluation error [E0080] diff --git a/src/test/compile-fail/const-eval-overflow-4b.rs b/src/test/compile-fail/const-eval-overflow-4b.rs index 9e7a5ecae10..02072e9a1a1 100644 --- a/src/test/compile-fail/const-eval-overflow-4b.rs +++ b/src/test/compile-fail/const-eval-overflow-4b.rs @@ -20,8 +20,9 @@ use std::{u8, u16, u32, u64, usize}; const A_I8_T : [u32; (i8::MAX as i8 + 1u8) as usize] - //~^ ERROR constant evaluation error [E0080] + //~^ ERROR mismatched types //~| expected i8, found u8 + //~| ERROR the trait bound `i8: std::ops::Add<u8>` is not satisfied = [0; (i8::MAX as usize) + 1]; @@ -32,8 +33,7 @@ const A_CHAR_USIZE const A_BAD_CHAR_USIZE : [u32; 5i8 as char as usize] - //~^ ERROR constant evaluation error - //~| only `u8` can be cast as `char`, not `i8` + //~^ ERROR only `u8` can be cast as `char`, not `i8` = [0; 5]; fn main() {} diff --git a/src/test/compile-fail/const-eval-span.rs b/src/test/compile-fail/const-eval-span.rs index 73351429b50..16f89606b01 100644 --- a/src/test/compile-fail/const-eval-span.rs +++ b/src/test/compile-fail/const-eval-span.rs @@ -14,12 +14,13 @@ struct S(i32); const CONSTANT: S = S(0); -//~^ ERROR E0080 -//~| unimplemented constant expression: tuple struct constructors enum E { V = CONSTANT, - //~^ NOTE: for enum discriminant here + //~^ ERROR mismatched types + //~| expected isize, found struct `S` + //~| NOTE expected type `isize` + //~| found type `S` } fn main() {} diff --git a/src/test/compile-fail/const-integer-bool-ops.rs b/src/test/compile-fail/const-integer-bool-ops.rs index 398dc2f2215..29bc665a22e 100644 --- a/src/test/compile-fail/const-integer-bool-ops.rs +++ b/src/test/compile-fail/const-integer-bool-ops.rs @@ -8,52 +8,71 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const X: usize = 42 && 39; //~ ERROR E0080 - //~| can't do this op on integrals -const ARR: [i32; X] = [99; 34]; //~ NOTE: for array length here +const X: usize = 42 && 39; +//~^ ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected usize, found bool +const ARR: [i32; X] = [99; 34]; -const X1: usize = 42 || 39; //~ ERROR E0080 - //~| can't do this op on integrals -const ARR1: [i32; X1] = [99; 47]; //~ NOTE: for array length here +const X1: usize = 42 || 39; +//~^ ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected usize, found bool +const ARR1: [i32; X1] = [99; 47]; -const X2: usize = -42 || -39; //~ ERROR E0080 - //~| unary negation of unsigned integer -const ARR2: [i32; X2] = [99; 18446744073709551607]; //~ NOTE: for array length here +const X2: usize = -42 || -39; +//~^ ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected usize, found bool +const ARR2: [i32; X2] = [99; 18446744073709551607]; -const X3: usize = -42 && -39; //~ ERROR E0080 - //~| unary negation of unsigned integer -const ARR3: [i32; X3] = [99; 6]; //~ NOTE: for array length here +const X3: usize = -42 && -39; +//~^ ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected usize, found bool +const ARR3: [i32; X3] = [99; 6]; const Y: usize = 42.0 == 42.0; +//~^ ERROR mismatched types +//~| expected usize, found bool const ARRR: [i32; Y] = [99; 1]; -//~^ ERROR: expected `usize` for array length, found boolean [E0306] -//~| NOTE expected `usize` const Y1: usize = 42.0 >= 42.0; -const ARRR1: [i32; Y] = [99; 1]; -//~^ ERROR: expected `usize` for array length, found boolean [E0306] -//~| NOTE expected `usize` +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR1: [i32; Y1] = [99; 1]; const Y2: usize = 42.0 <= 42.0; -const ARRR2: [i32; Y] = [99; 1]; -//~^ ERROR: expected `usize` for array length, found boolean [E0306] -//~| NOTE expected `usize` +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR2: [i32; Y2] = [99; 1]; const Y3: usize = 42.0 > 42.0; -const ARRR3: [i32; Y] = [99; 0]; -//~^ ERROR: expected `usize` for array length, found boolean [E0306] -//~| NOTE expected `usize` +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR3: [i32; Y3] = [99; 0]; const Y4: usize = 42.0 < 42.0; -const ARRR4: [i32; Y] = [99; 0]; -//~^ ERROR: expected `usize` for array length, found boolean [E0306] -//~| NOTE expected `usize` +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR4: [i32; Y4] = [99; 0]; const Y5: usize = 42.0 != 42.0; -const ARRR5: [i32; Y] = [99; 0]; -//~^ ERROR: expected `usize` for array length, found boolean [E0306] -//~| NOTE expected `usize` - +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR5: [i32; Y5] = [99; 0]; fn main() { let _ = ARR; diff --git a/src/test/compile-fail/const-tup-index-span.rs b/src/test/compile-fail/const-tup-index-span.rs index f3fb92e2b22..b42c440f87d 100644 --- a/src/test/compile-fail/const-tup-index-span.rs +++ b/src/test/compile-fail/const-tup-index-span.rs @@ -11,8 +11,8 @@ // Test spans of errors const TUP: (usize,) = 5usize << 64; -//~^ ERROR E0080 -//~| attempt to shift left with overflow +//~^ ERROR mismatched types +//~| expected tuple, found usize const ARR: [i32; TUP.0] = []; fn main() { diff --git a/src/test/compile-fail/discrim-ill-typed.rs b/src/test/compile-fail/discrim-ill-typed.rs index c73b7e831b3..62e54c3f237 100644 --- a/src/test/compile-fail/discrim-ill-typed.rs +++ b/src/test/compile-fail/discrim-ill-typed.rs @@ -25,7 +25,7 @@ fn f_i8() { Ok = i8::MAX - 1, Ok2, OhNo = 0_u8, - //~^ ERROR E0080 + //~^ ERROR mismatched types //~| expected i8, found u8 } @@ -38,7 +38,7 @@ fn f_u8() { Ok = u8::MAX - 1, Ok2, OhNo = 0_i8, - //~^ ERROR E0080 + //~^ ERROR mismatched types //~| expected u8, found i8 } @@ -51,7 +51,7 @@ fn f_i16() { Ok = i16::MAX - 1, Ok2, OhNo = 0_u16, - //~^ ERROR E0080 + //~^ ERROR mismatched types //~| expected i16, found u16 } @@ -64,7 +64,7 @@ fn f_u16() { Ok = u16::MAX - 1, Ok2, OhNo = 0_i16, - //~^ ERROR E0080 + //~^ ERROR mismatched types //~| expected u16, found i16 } @@ -77,7 +77,7 @@ fn f_i32() { Ok = i32::MAX - 1, Ok2, OhNo = 0_u32, - //~^ ERROR E0080 + //~^ ERROR mismatched types //~| expected i32, found u32 } @@ -90,7 +90,7 @@ fn f_u32() { Ok = u32::MAX - 1, Ok2, OhNo = 0_i32, - //~^ ERROR E0080 + //~^ ERROR mismatched types //~| expected u32, found i32 } @@ -103,7 +103,7 @@ fn f_i64() { Ok = i64::MAX - 1, Ok2, OhNo = 0_u64, - //~^ ERROR E0080 + //~^ ERROR mismatched types //~| expected i64, found u64 } @@ -116,7 +116,7 @@ fn f_u64() { Ok = u64::MAX - 1, Ok2, OhNo = 0_i64, - //~^ ERROR E0080 + //~^ ERROR mismatched types //~| expected u64, found i64 } diff --git a/src/test/compile-fail/enum-discrim-too-small.rs b/src/test/compile-fail/enum-discrim-too-small.rs index bbdb3891d99..393a67be57f 100644 --- a/src/test/compile-fail/enum-discrim-too-small.rs +++ b/src/test/compile-fail/enum-discrim-too-small.rs @@ -13,32 +13,32 @@ enum Eu8 { Au8 = 23, Bu8 = 223, - Cu8 = -23, //~ ERROR E0080 - //~| unary negation of unsigned integer + Cu8 = -23, + //~^ ERROR cannot apply unary operator `-` to type `u8` } #[repr(u16)] enum Eu16 { Au16 = 23, Bu16 = 55555, - Cu16 = -22333, //~ ERROR E0080 - //~| unary negation of unsigned integer + Cu16 = -22333, + //~^ ERROR cannot apply unary operator `-` to type `u16` } #[repr(u32)] enum Eu32 { Au32 = 23, Bu32 = 3_000_000_000, - Cu32 = -2_000_000_000, //~ ERROR E0080 - //~| unary negation of unsigned integer + Cu32 = -2_000_000_000, + //~^ ERROR cannot apply unary operator `-` to type `u32` } #[repr(u64)] enum Eu64 { Au32 = 23, Bu32 = 3_000_000_000, - Cu32 = -2_000_000_000, //~ ERROR E0080 - //~| unary negation of unsigned integer + Cu32 = -2_000_000_000, + //~^ ERROR cannot apply unary operator `-` to type `u64` } // u64 currently allows negative numbers, and i64 allows numbers greater than `1<<63`. This is a diff --git a/src/test/compile-fail/invalid-path-in-const.rs b/src/test/compile-fail/invalid-path-in-const.rs index 9a9358b787f..ab839e7630d 100644 --- a/src/test/compile-fail/invalid-path-in-const.rs +++ b/src/test/compile-fail/invalid-path-in-const.rs @@ -10,6 +10,5 @@ fn main() { fn f(a: [u8; u32::DOESNOTEXIST]) {} - //~^ ERROR constant evaluation error - //~| unresolved path in constant expression + //~^ ERROR no associated item named `DOESNOTEXIST` found for type `u32` } diff --git a/src/test/compile-fail/issue-22933-2.rs b/src/test/compile-fail/issue-22933-2.rs index 54a24089354..c78e1f7f530 100644 --- a/src/test/compile-fail/issue-22933-2.rs +++ b/src/test/compile-fail/issue-22933-2.rs @@ -12,12 +12,10 @@ enum Delicious { Pie = 0x1, Apple = 0x2, ApplePie = Delicious::Apple as isize | Delicious::PIE as isize, - //~^ ERROR constant evaluation error - //~| unresolved path in constant expression + //~^ ERROR no associated item named `PIE` found for type `Delicious` } const FOO: [u32; u8::MIN as usize] = []; -//~^ ERROR constant evaluation error -//~| unresolved path in constant expression +//~^ ERROR no associated item named `MIN` found for type `u8` fn main() {} diff --git a/src/test/compile-fail/issue-23217.rs b/src/test/compile-fail/issue-23217.rs index c2bcbb9d54a..95f6526f115 100644 --- a/src/test/compile-fail/issue-23217.rs +++ b/src/test/compile-fail/issue-23217.rs @@ -10,8 +10,7 @@ pub enum SomeEnum { B = SomeEnum::A, - //~^ ERROR constant evaluation error - //~| unresolved path in constant expression + //~^ ERROR no associated item named `A` found for type `SomeEnum` } fn main() {} diff --git a/src/test/compile-fail/issue-28586.rs b/src/test/compile-fail/issue-28586.rs index 1dfd146985f..b8571d2e85e 100644 --- a/src/test/compile-fail/issue-28586.rs +++ b/src/test/compile-fail/issue-28586.rs @@ -11,6 +11,7 @@ // Regression test for issue #28586 pub trait Foo {} -impl Foo for [u8; usize::BYTES] {} //~ ERROR E0080 +impl Foo for [u8; usize::BYTES] {} +//~^ ERROR no associated item named `BYTES` found for type `usize` fn main() { } diff --git a/src/test/compile-fail/issue-31910.rs b/src/test/compile-fail/issue-31910.rs index 65fcd7df77e..aac8b89e882 100644 --- a/src/test/compile-fail/issue-31910.rs +++ b/src/test/compile-fail/issue-31910.rs @@ -11,7 +11,9 @@ #![feature(associated_consts)] enum Enum<T: Trait> { - X = Trait::Number, //~ ERROR constant evaluation error + X = Trait::Number, + //~^ ERROR mismatched types + //~| expected isize, found i32 } trait Trait { diff --git a/src/test/compile-fail/issue-3521.rs b/src/test/compile-fail/issue-3521.rs index e2acdcee3de..78af11a0b58 100644 --- a/src/test/compile-fail/issue-3521.rs +++ b/src/test/compile-fail/issue-3521.rs @@ -15,9 +15,7 @@ fn main() { enum Stuff { Bar = foo //~^ ERROR attempt to use a non-constant value in a constant - //~^^ ERROR constant evaluation error - //~| unresolved path in constant expression } - println!("{}", Stuff::Bar); + println!("{:?}", Stuff::Bar); } diff --git a/src/test/compile-fail/issue-39559.rs b/src/test/compile-fail/issue-39559.rs index a56a5e85489..bc492806b96 100644 --- a/src/test/compile-fail/issue-39559.rs +++ b/src/test/compile-fail/issue-39559.rs @@ -23,9 +23,13 @@ impl Dim for Dim3 { pub struct Vector<T, D: Dim> { entries: [T; D::dim()] //~^ ERROR cannot use an outer type parameter in this context - //~| ERROR constant evaluation error } fn main() { - let array: [usize; Dim3::dim()] = [0; Dim3::dim()]; + let array: [usize; Dim3::dim()] + //~^ ERROR constant evaluation error + //~| non-constant path in constant expression + = [0; Dim3::dim()]; + //~^ ERROR constant evaluation error + //~| non-constant path in constant expression } diff --git a/src/test/compile-fail/issue-8761.rs b/src/test/compile-fail/issue-8761.rs index 91a07dd9ba6..f8424ea64ef 100644 --- a/src/test/compile-fail/issue-8761.rs +++ b/src/test/compile-fail/issue-8761.rs @@ -10,10 +10,10 @@ enum Foo { A = 1i64, - //~^ ERROR constant evaluation error + //~^ ERROR mismatched types //~| expected isize, found i64 B = 2u8 - //~^ ERROR constant evaluation error + //~^ ERROR mismatched types //~| expected isize, found u8 } diff --git a/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs b/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs index 691d8d31b41..52cd4e8a3ed 100644 --- a/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs +++ b/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs @@ -14,6 +14,5 @@ fn main() { fn bar(n: isize) { let _x: [isize; n]; //~^ ERROR attempt to use a non-constant value in a constant [E0435] - //~| ERROR constant evaluation error [E0080] } } diff --git a/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs b/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs index f4769a78587..1eda5087784 100644 --- a/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs +++ b/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs @@ -15,7 +15,5 @@ fn main() { let _x = [0; n]; //~^ ERROR attempt to use a non-constant value in a constant [E0435] //~| NOTE non-constant used with constant - //~| NOTE unresolved path in constant expression - //~| ERROR constant evaluation error [E0080] } } diff --git a/src/test/mir-opt/simplify_if.rs b/src/test/mir-opt/simplify_if.rs index 0e8971269b0..6e80a917467 100644 --- a/src/test/mir-opt/simplify_if.rs +++ b/src/test/mir-opt/simplify_if.rs @@ -17,7 +17,7 @@ fn main() { // END RUST SOURCE // START rustc.node4.SimplifyBranches.initial-before.mir // bb0: { -// switchInt(const false) -> [0: bb2, otherwise: bb1]; +// switchInt(const false) -> [0u8: bb2, otherwise: bb1]; // } // END rustc.node4.SimplifyBranches.initial-before.mir // START rustc.node4.SimplifyBranches.initial-after.mir diff --git a/src/test/compile-fail/issue-25145.rs b/src/test/run-pass/issue-25145.rs index 93f75e9bfed..6f02f278381 100644 --- a/src/test/compile-fail/issue-25145.rs +++ b/src/test/run-pass/issue-25145.rs @@ -17,7 +17,7 @@ impl S { } static STUFF: [u8; S::N] = [0; S::N]; -//~^ ERROR constant evaluation error -//~| unresolved path in constant expression -fn main() {} +fn main() { + assert_eq!(STUFF, [0; 3]); +} diff --git a/src/test/compile-fail/E0079.rs b/src/test/run-pass/issue-39548.rs index c9b7f549d5a..7da50670d1d 100644 --- a/src/test/compile-fail/E0079.rs +++ b/src/test/run-pass/issue-39548.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum Foo { - Q = "32" //~ ERROR E0079 - //~^ expected 'isize' type -} +type Array = [(); ((1 < 2) == false) as usize]; fn main() { + let _: Array = []; } diff --git a/src/test/ui/resolve/levenshtein.stderr b/src/test/ui/resolve/levenshtein.stderr index d01ffcb2839..c7c42bcf239 100644 --- a/src/test/ui/resolve/levenshtein.stderr +++ b/src/test/ui/resolve/levenshtein.stderr @@ -46,11 +46,5 @@ error[E0425]: cannot find value `second` in module `m` 32 | let b: m::first = m::second; // Misspelled item in module. | ^^^^^^^^^ did you mean `m::Second`? -error[E0080]: constant evaluation error - --> $DIR/levenshtein.rs:30:20 - | -30 | let v = [0u32; MAXITEM]; // Misspelled constant name. - | ^^^^^^^ unresolved path in constant expression - -error: aborting due to previous error +error: aborting due to 8 previous errors |
