Auto merge of #69105 - Dylan-DPC:rollup-n73lh5h, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #67954 (Support new LLVM pass manager) - #68981 ( Account for type params on method without parentheses) - #69002 (miri: improve and simplify overflow detection) - #69038 (Add initial debug fmt for Backtrace) - #69040 (Cleanup SGX entry code) - #69086 (Update compiler-builtins to 0.1.25) - #69095 (Minified theme check) Failed merges: r? @ghost
This commit is contained in:
commit
92d8e82f6b
34 changed files with 892 additions and 179 deletions
|
|
@ -15,10 +15,10 @@
|
|||
#![crate_type="lib"]
|
||||
|
||||
// MSAN-0-NOT: @__msan_track_origins
|
||||
// MSAN-1: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 1
|
||||
// MSAN-2: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 2
|
||||
// MSAN-1-LTO: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 1
|
||||
// MSAN-2-LTO: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 2
|
||||
// MSAN-1: @__msan_track_origins = weak_odr {{.*}}constant i32 1
|
||||
// MSAN-2: @__msan_track_origins = weak_odr {{.*}}constant i32 2
|
||||
// MSAN-1-LTO: @__msan_track_origins = weak_odr {{.*}}constant i32 1
|
||||
// MSAN-2-LTO: @__msan_track_origins = weak_odr {{.*}}constant i32 2
|
||||
//
|
||||
// MSAN-0-LABEL: define void @copy(
|
||||
// MSAN-1-LABEL: define void @copy(
|
||||
|
|
|
|||
|
|
@ -17,16 +17,22 @@ fn black_box<T>(_: T) {
|
|||
fn main() {
|
||||
let a = -std::i8::MIN;
|
||||
//~^ ERROR const_err
|
||||
let a_i128 = -std::i128::MIN;
|
||||
//~^ ERROR const_err
|
||||
let b = 200u8 + 200u8 + 200u8;
|
||||
//~^ ERROR const_err
|
||||
let b_i128 = std::i128::MIN - std::i128::MAX;
|
||||
//~^ ERROR const_err
|
||||
let c = 200u8 * 4;
|
||||
//~^ ERROR const_err
|
||||
let d = 42u8 - (42u8 + 1);
|
||||
//~^ ERROR const_err
|
||||
let _e = [5u8][1];
|
||||
//~^ ERROR index out of bounds
|
||||
//~^ ERROR const_err
|
||||
black_box(a);
|
||||
black_box(a_i128);
|
||||
black_box(b);
|
||||
black_box(b_i128);
|
||||
black_box(c);
|
||||
black_box(d);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,28 +11,40 @@ LL | #![deny(const_err)]
|
|||
| ^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/const-err2.rs:20:13
|
||||
--> $DIR/const-err2.rs:20:18
|
||||
|
|
||||
LL | let a_i128 = -std::i128::MIN;
|
||||
| ^^^^^^^^^^^^^^^ attempt to negate with overflow
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/const-err2.rs:22:13
|
||||
|
|
||||
LL | let b = 200u8 + 200u8 + 200u8;
|
||||
| ^^^^^^^^^^^^^ attempt to add with overflow
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/const-err2.rs:22:13
|
||||
--> $DIR/const-err2.rs:24:18
|
||||
|
|
||||
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/const-err2.rs:26:13
|
||||
|
|
||||
LL | let c = 200u8 * 4;
|
||||
| ^^^^^^^^^ attempt to multiply with overflow
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/const-err2.rs:24:13
|
||||
--> $DIR/const-err2.rs:28:13
|
||||
|
|
||||
LL | let d = 42u8 - (42u8 + 1);
|
||||
| ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
|
||||
|
||||
error: index out of bounds: the len is 1 but the index is 1
|
||||
--> $DIR/const-err2.rs:26:14
|
||||
--> $DIR/const-err2.rs:30:14
|
||||
|
|
||||
LL | let _e = [5u8][1];
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,12 @@ fn black_box<T>(_: T) {
|
|||
fn main() {
|
||||
let a = -std::i8::MIN;
|
||||
//~^ ERROR const_err
|
||||
let a_i128 = -std::i128::MIN;
|
||||
//~^ ERROR const_err
|
||||
let b = 200u8 + 200u8 + 200u8;
|
||||
//~^ ERROR const_err
|
||||
let b_i128 = std::i128::MIN - std::i128::MAX;
|
||||
//~^ ERROR const_err
|
||||
let c = 200u8 * 4;
|
||||
//~^ ERROR const_err
|
||||
let d = 42u8 - (42u8 + 1);
|
||||
|
|
@ -26,7 +30,9 @@ fn main() {
|
|||
let _e = [5u8][1];
|
||||
//~^ ERROR const_err
|
||||
black_box(a);
|
||||
black_box(a_i128);
|
||||
black_box(b);
|
||||
black_box(b_i128);
|
||||
black_box(c);
|
||||
black_box(d);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,29 +10,41 @@ note: the lint level is defined here
|
|||
LL | #![deny(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: attempt to negate with overflow
|
||||
--> $DIR/const-err3.rs:20:18
|
||||
|
|
||||
LL | let a_i128 = -std::i128::MIN;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to add with overflow
|
||||
--> $DIR/const-err3.rs:20:13
|
||||
--> $DIR/const-err3.rs:22:13
|
||||
|
|
||||
LL | let b = 200u8 + 200u8 + 200u8;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to subtract with overflow
|
||||
--> $DIR/const-err3.rs:24:18
|
||||
|
|
||||
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to multiply with overflow
|
||||
--> $DIR/const-err3.rs:22:13
|
||||
--> $DIR/const-err3.rs:26:13
|
||||
|
|
||||
LL | let c = 200u8 * 4;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: attempt to subtract with overflow
|
||||
--> $DIR/const-err3.rs:24:13
|
||||
--> $DIR/const-err3.rs:28:13
|
||||
|
|
||||
LL | let d = 42u8 - (42u8 + 1);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: index out of bounds: the len is 1 but the index is 1
|
||||
--> $DIR/const-err3.rs:26:14
|
||||
--> $DIR/const-err3.rs:30:14
|
||||
|
|
||||
LL | let _e = [5u8][1];
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
|
|||
26
src/test/ui/consts/const-int-arithmetic-overflow.rs
Normal file
26
src/test/ui/consts/const-int-arithmetic-overflow.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// run-pass
|
||||
// compile-flags: -O
|
||||
#![allow(const_err)]
|
||||
|
||||
// Make sure arithmetic unary/binary ops actually return the right result, even when overflowing.
|
||||
// We have to put them in `const fn` and turn on optimizations to avoid overflow checks.
|
||||
|
||||
const fn add(x: i8, y: i8) -> i8 { x+y }
|
||||
const fn sub(x: i8, y: i8) -> i8 { x-y }
|
||||
const fn mul(x: i8, y: i8) -> i8 { x*y }
|
||||
// div and rem are always checked, so we cannot test their result in case of oveflow.
|
||||
const fn neg(x: i8) -> i8 { -x }
|
||||
|
||||
fn main() {
|
||||
const ADD_OFLOW: i8 = add(100, 100);
|
||||
assert_eq!(ADD_OFLOW, -56);
|
||||
|
||||
const SUB_OFLOW: i8 = sub(100, -100);
|
||||
assert_eq!(SUB_OFLOW, -56);
|
||||
|
||||
const MUL_OFLOW: i8 = mul(-100, -2);
|
||||
assert_eq!(MUL_OFLOW, -56);
|
||||
|
||||
const NEG_OFLOW: i8 = neg(-128);
|
||||
assert_eq!(NEG_OFLOW, -128);
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
#![feature(const_saturating_int_methods)]
|
||||
#![feature(const_wrapping_int_methods)]
|
||||
|
||||
use std::i8;
|
||||
use std::{i8, i128};
|
||||
|
||||
macro_rules! suite {
|
||||
($(
|
||||
|
|
@ -65,6 +65,10 @@ suite!(
|
|||
C26: 5i8.checked_rem_euclid(0), None;
|
||||
C27: i8::MIN.checked_rem_euclid(-1), None;
|
||||
}
|
||||
checked_i128 -> Option<i128> {
|
||||
CHK_ADD_I128: i128::MAX.checked_add(1), None;
|
||||
CHK_MUL_I128: i128::MIN.checked_mul(-1), None;
|
||||
}
|
||||
|
||||
saturating_and_wrapping -> i8 {
|
||||
// `const_saturating_int_methods`
|
||||
|
|
@ -104,6 +108,13 @@ suite!(
|
|||
C47: 100i8.wrapping_rem_euclid(10), 0;
|
||||
C48: (-128i8).wrapping_rem_euclid(-1), 0;
|
||||
}
|
||||
saturating_and_wrapping_i128 -> i128 {
|
||||
SAT_ADD_I128: i128::MAX.saturating_add(1), i128::MAX;
|
||||
SAT_MUL_I128: i128::MAX.saturating_mul(2), i128::MAX;
|
||||
|
||||
WRP_ADD_I128: i128::MAX.wrapping_add(1), i128::MIN;
|
||||
WRP_MUL_I128: i128::MAX.wrapping_mul(3), i128::MAX-2;
|
||||
}
|
||||
|
||||
overflowing -> (i8, bool) {
|
||||
// `const_overflowing_int_methods`
|
||||
|
|
@ -119,12 +130,18 @@ suite!(
|
|||
|
||||
C55: 5i8.overflowing_rem_euclid(2), (1, false);
|
||||
C56: i8::MIN.overflowing_rem_euclid(-1), (0, true);
|
||||
|
||||
}
|
||||
overflowing_i128 -> (i128, bool) {
|
||||
OFL_ADD_I128: i128::MAX.overflowing_add(1), (i128::MIN, true);
|
||||
OFL_MUL_I128: i128::MAX.overflowing_mul(3), (i128::MAX-2, true);
|
||||
}
|
||||
);
|
||||
|
||||
fn main() {
|
||||
checked();
|
||||
checked_i128();
|
||||
saturating_and_wrapping();
|
||||
saturating_and_wrapping_i128();
|
||||
overflowing();
|
||||
overflowing_i128();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#![deny(const_err)]
|
||||
|
||||
use std::{isize, i8, i16, i32, i64};
|
||||
use std::{isize, i8, i16, i32, i64, i128};
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
|
|
@ -22,6 +22,9 @@ fn main() {
|
|||
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempt to divide with overflow
|
||||
//~| ERROR this expression will panic at runtime
|
||||
assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempt to divide with overflow
|
||||
//~| ERROR this expression will panic at runtime
|
||||
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
|
||||
|
|
@ -32,6 +35,8 @@ fn main() {
|
|||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
//~| ERROR this expression will panic at runtime
|
||||
|
|
@ -47,6 +52,9 @@ fn main() {
|
|||
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
//~| ERROR this expression will panic at runtime
|
||||
assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
//~| ERROR this expression will panic at runtime
|
||||
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
|
||||
|
|
@ -57,4 +65,6 @@ fn main() {
|
|||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,125 +64,161 @@ error: this expression will panic at runtime
|
|||
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^ attempt to divide with overflow
|
||||
|
||||
error: attempt to divide by zero
|
||||
error: attempt to divide with overflow
|
||||
--> $DIR/issue-8460-const.rs:25:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:25:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^ attempt to divide with overflow
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:28:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:27:36
|
||||
--> $DIR/issue-8460-const.rs:30:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
|
||||
| ^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:29:36
|
||||
--> $DIR/issue-8460-const.rs:32:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:31:36
|
||||
--> $DIR/issue-8460-const.rs:34:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:33:36
|
||||
--> $DIR/issue-8460-const.rs:36:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:38:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:35:36
|
||||
--> $DIR/issue-8460-const.rs:40:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:35:36
|
||||
--> $DIR/issue-8460-const.rs:40:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:38:36
|
||||
--> $DIR/issue-8460-const.rs:43:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:38:36
|
||||
--> $DIR/issue-8460-const.rs:43:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:41:36
|
||||
--> $DIR/issue-8460-const.rs:46:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:41:36
|
||||
--> $DIR/issue-8460-const.rs:46:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:44:36
|
||||
--> $DIR/issue-8460-const.rs:49:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:44:36
|
||||
--> $DIR/issue-8460-const.rs:49:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:47:36
|
||||
--> $DIR/issue-8460-const.rs:52:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:47:36
|
||||
--> $DIR/issue-8460-const.rs:52:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:55:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:55:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:50:36
|
||||
--> $DIR/issue-8460-const.rs:58:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:52:36
|
||||
--> $DIR/issue-8460-const.rs:60:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
|
||||
| ^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:54:36
|
||||
--> $DIR/issue-8460-const.rs:62:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:56:36
|
||||
--> $DIR/issue-8460-const.rs:64:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:58:36
|
||||
--> $DIR/issue-8460-const.rs:66:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 30 previous errors
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:68:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#![deny(const_err)]
|
||||
|
||||
use std::{isize, i8, i16, i32, i64};
|
||||
use std::{isize, i8, i16, i32, i64, i128};
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
|
|
@ -17,6 +17,8 @@ fn main() {
|
|||
//~^ ERROR attempt to divide with overflow
|
||||
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempt to divide with overflow
|
||||
assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempt to divide with overflow
|
||||
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
|
||||
|
|
@ -27,6 +29,8 @@ fn main() {
|
|||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
|
||||
|
|
@ -37,6 +41,8 @@ fn main() {
|
|||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
|
||||
|
|
@ -47,4 +53,6 @@ fn main() {
|
|||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,95 +34,119 @@ error: attempt to divide with overflow
|
|||
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
error: attempt to divide with overflow
|
||||
--> $DIR/issue-8460-const2.rs:20:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:22:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:22:36
|
||||
--> $DIR/issue-8460-const2.rs:24:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
|
||||
| ^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:24:36
|
||||
--> $DIR/issue-8460-const2.rs:26:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:26:36
|
||||
--> $DIR/issue-8460-const2.rs:28:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:28:36
|
||||
--> $DIR/issue-8460-const2.rs:30:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:32:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const2.rs:30:36
|
||||
--> $DIR/issue-8460-const2.rs:34:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const2.rs:32:36
|
||||
--> $DIR/issue-8460-const2.rs:36:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const2.rs:34:36
|
||||
--> $DIR/issue-8460-const2.rs:38:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const2.rs:36:36
|
||||
--> $DIR/issue-8460-const2.rs:40:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const2.rs:38:36
|
||||
--> $DIR/issue-8460-const2.rs:42:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const2.rs:44:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:40:36
|
||||
--> $DIR/issue-8460-const2.rs:46:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:42:36
|
||||
--> $DIR/issue-8460-const2.rs:48:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
|
||||
| ^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:44:36
|
||||
--> $DIR/issue-8460-const2.rs:50:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:46:36
|
||||
--> $DIR/issue-8460-const2.rs:52:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:48:36
|
||||
--> $DIR/issue-8460-const2.rs:54:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 20 previous errors
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:56:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 24 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ fn main() {
|
|||
y: 2,
|
||||
};
|
||||
f.x::<isize>;
|
||||
//~^ ERROR field expressions may not have generic arguments
|
||||
//~^ ERROR field expressions cannot have generic arguments
|
||||
f.x::<>;
|
||||
//~^ ERROR field expressions may not have generic arguments
|
||||
//~^ ERROR field expressions cannot have generic arguments
|
||||
f.x::();
|
||||
//~^ ERROR field expressions may not have generic arguments
|
||||
//~^ ERROR field expressions cannot have generic arguments
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
error: field expressions may not have generic arguments
|
||||
error: field expressions cannot have generic arguments
|
||||
--> $DIR/type-parameters-in-field-exprs.rs:11:10
|
||||
|
|
||||
LL | f.x::<isize>;
|
||||
| ^^^^^^^
|
||||
|
||||
error: field expressions may not have generic arguments
|
||||
error: field expressions cannot have generic arguments
|
||||
--> $DIR/type-parameters-in-field-exprs.rs:13:10
|
||||
|
|
||||
LL | f.x::<>;
|
||||
| ^^
|
||||
|
||||
error: field expressions may not have generic arguments
|
||||
error: field expressions cannot have generic arguments
|
||||
--> $DIR/type-parameters-in-field-exprs.rs:15:7
|
||||
|
|
||||
LL | f.x::();
|
||||
|
|
|
|||
5
src/test/ui/suggestions/method-missing-parentheses.rs
Normal file
5
src/test/ui/suggestions/method-missing-parentheses.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {
|
||||
let _ = vec![].into_iter().collect::<usize>;
|
||||
//~^ ERROR attempted to take value of method `collect` on type `std::vec::IntoIter<_>`
|
||||
//~| ERROR field expressions cannot have generic arguments
|
||||
}
|
||||
17
src/test/ui/suggestions/method-missing-parentheses.stderr
Normal file
17
src/test/ui/suggestions/method-missing-parentheses.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error: field expressions cannot have generic arguments
|
||||
--> $DIR/method-missing-parentheses.rs:2:41
|
||||
|
|
||||
LL | let _ = vec![].into_iter().collect::<usize>;
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0615]: attempted to take value of method `collect` on type `std::vec::IntoIter<_>`
|
||||
--> $DIR/method-missing-parentheses.rs:2:32
|
||||
|
|
||||
LL | let _ = vec![].into_iter().collect::<usize>;
|
||||
| ^^^^^^^---------
|
||||
| |
|
||||
| help: use parentheses to call the method: `collect::<usize>()`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0615`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue