Skip to content

Commit a937d8c

Browse files
committedSep 1, 2019
Fix tests again
1 parent 0cd9c16 commit a937d8c

14 files changed

+542
-72
lines changed
 

‎src/test/ui/consts/const-err2.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#![feature(rustc_attrs)]
77
#![allow(exceeding_bitshifts)]
8-
// compile-flags: -C overflow-checks=on -O
98

109
#![deny(const_err)]
1110

@@ -23,7 +22,7 @@ fn main() {
2322
let d = 42u8 - (42u8 + 1);
2423
//~^ ERROR const_err
2524
let _e = [5u8][1];
26-
//~^ ERROR const_err
25+
//~^ ERROR index out of bounds
2726
black_box(a);
2827
black_box(b);
2928
black_box(c);

‎src/test/ui/consts/const-err2.stderr

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
error: attempt to negate with overflow
2-
--> $DIR/const-err2.rs:17:13
1+
error: this expression will panic at runtime
2+
--> $DIR/const-err2.rs:16:13
33
|
44
LL | let a = -std::i8::MIN;
5-
| ^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^ attempt to negate with overflow
66
|
77
note: lint level defined here
8-
--> $DIR/const-err2.rs:10:9
8+
--> $DIR/const-err2.rs:9:9
99
|
1010
LL | #![deny(const_err)]
1111
| ^^^^^^^^^
1212

13-
error: attempt to add with overflow
14-
--> $DIR/const-err2.rs:19:13
13+
error: this expression will panic at runtime
14+
--> $DIR/const-err2.rs:18:13
1515
|
1616
LL | let b = 200u8 + 200u8 + 200u8;
17-
| ^^^^^^^^^^^^^
17+
| ^^^^^^^^^^^^^ attempt to add with overflow
1818

19-
error: attempt to multiply with overflow
20-
--> $DIR/const-err2.rs:21:13
19+
error: this expression will panic at runtime
20+
--> $DIR/const-err2.rs:20:13
2121
|
2222
LL | let c = 200u8 * 4;
23-
| ^^^^^^^^^
23+
| ^^^^^^^^^ attempt to multiply with overflow
2424

25-
error: attempt to subtract with overflow
26-
--> $DIR/const-err2.rs:23:13
25+
error: this expression will panic at runtime
26+
--> $DIR/const-err2.rs:22:13
2727
|
2828
LL | let d = 42u8 - (42u8 + 1);
29-
| ^^^^^^^^^^^^^^^^^
29+
| ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
3030

3131
error: index out of bounds: the len is 1 but the index is 1
32-
--> $DIR/const-err2.rs:25:14
32+
--> $DIR/const-err2.rs:24:14
3333
|
3434
LL | let _e = [5u8][1];
3535
| ^^^^^^^^

‎src/test/ui/consts/const-err3.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// needed because negating int::MIN will behave differently between
2+
// optimized compilation and unoptimized compilation and thus would
3+
// lead to different lints being emitted
4+
// compile-flags: -C overflow-checks=on -O
5+
6+
#![feature(rustc_attrs)]
7+
#![allow(exceeding_bitshifts)]
8+
9+
#![deny(const_err)]
10+
11+
fn black_box<T>(_: T) {
12+
unimplemented!()
13+
}
14+
15+
fn main() {
16+
let a = -std::i8::MIN;
17+
//~^ ERROR const_err
18+
let b = 200u8 + 200u8 + 200u8;
19+
//~^ ERROR const_err
20+
let c = 200u8 * 4;
21+
//~^ ERROR const_err
22+
let d = 42u8 - (42u8 + 1);
23+
//~^ ERROR const_err
24+
let _e = [5u8][1];
25+
//~^ ERROR const_err
26+
black_box(a);
27+
black_box(b);
28+
black_box(c);
29+
black_box(d);
30+
}

‎src/test/ui/consts/const-err3.stderr

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error: attempt to negate with overflow
2+
--> $DIR/const-err3.rs:16:13
3+
|
4+
LL | let a = -std::i8::MIN;
5+
| ^^^^^^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/const-err3.rs:9:9
9+
|
10+
LL | #![deny(const_err)]
11+
| ^^^^^^^^^
12+
13+
error: attempt to add with overflow
14+
--> $DIR/const-err3.rs:18:13
15+
|
16+
LL | let b = 200u8 + 200u8 + 200u8;
17+
| ^^^^^^^^^^^^^
18+
19+
error: attempt to multiply with overflow
20+
--> $DIR/const-err3.rs:20:13
21+
|
22+
LL | let c = 200u8 * 4;
23+
| ^^^^^^^^^
24+
25+
error: attempt to subtract with overflow
26+
--> $DIR/const-err3.rs:22:13
27+
|
28+
LL | let d = 42u8 - (42u8 + 1);
29+
| ^^^^^^^^^^^^^^^^^
30+
31+
error: index out of bounds: the len is 1 but the index is 1
32+
--> $DIR/const-err3.rs:24:14
33+
|
34+
LL | let _e = [5u8][1];
35+
| ^^^^^^^^
36+
37+
error: aborting due to 5 previous errors
38+

‎src/test/ui/consts/const-eval/promoted_errors.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// compile-flags: -C overflow-checks=on -O
1+
// compile-flags: -O
22

33
#![deny(const_err)]
44

55
fn main() {
66
println!("{}", 0u32 - 1);
7-
//~^ ERROR attempt to subtract with overflow
87
let _x = 0u32 - 1;
9-
//~^ ERROR attempt to subtract with overflow
8+
//~^ ERROR const_err
109
println!("{}", 1/(1-1));
1110
//~^ ERROR attempt to divide by zero [const_err]
1211
//~| ERROR reaching this expression at runtime will panic or abort [const_err]
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,62 @@
1-
error: attempt to subtract with overflow
2-
--> $DIR/promoted_errors.rs:6:20
1+
error: this expression will panic at runtime
2+
--> $DIR/promoted_errors.rs:7:14
33
|
4-
LL | println!("{}", 0u32 - 1);
5-
| ^^^^^^^^
4+
LL | let _x = 0u32 - 1;
5+
| ^^^^^^^^ attempt to subtract with overflow
66
|
77
note: lint level defined here
88
--> $DIR/promoted_errors.rs:3:9
99
|
1010
LL | #![deny(const_err)]
1111
| ^^^^^^^^^
1212

13-
error: attempt to subtract with overflow
14-
--> $DIR/promoted_errors.rs:8:14
15-
|
16-
LL | let _x = 0u32 - 1;
17-
| ^^^^^^^^
18-
1913
error: attempt to divide by zero
20-
--> $DIR/promoted_errors.rs:10:20
14+
--> $DIR/promoted_errors.rs:9:20
2115
|
2216
LL | println!("{}", 1/(1-1));
2317
| ^^^^^^^
2418

2519
error: reaching this expression at runtime will panic or abort
26-
--> $DIR/promoted_errors.rs:10:20
20+
--> $DIR/promoted_errors.rs:9:20
2721
|
2822
LL | println!("{}", 1/(1-1));
2923
| ^^^^^^^ attempt to divide by zero
3024

3125
error: attempt to divide by zero
32-
--> $DIR/promoted_errors.rs:13:14
26+
--> $DIR/promoted_errors.rs:12:14
3327
|
3428
LL | let _x = 1/(1-1);
3529
| ^^^^^^^
3630

3731
error: this expression will panic at runtime
38-
--> $DIR/promoted_errors.rs:13:14
32+
--> $DIR/promoted_errors.rs:12:14
3933
|
4034
LL | let _x = 1/(1-1);
4135
| ^^^^^^^ attempt to divide by zero
4236

4337
error: attempt to divide by zero
44-
--> $DIR/promoted_errors.rs:16:20
38+
--> $DIR/promoted_errors.rs:15:20
4539
|
4640
LL | println!("{}", 1/(false as u32));
4741
| ^^^^^^^^^^^^^^^^
4842

4943
error: reaching this expression at runtime will panic or abort
50-
--> $DIR/promoted_errors.rs:16:20
44+
--> $DIR/promoted_errors.rs:15:20
5145
|
5246
LL | println!("{}", 1/(false as u32));
5347
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
5448

5549
error: attempt to divide by zero
56-
--> $DIR/promoted_errors.rs:19:14
50+
--> $DIR/promoted_errors.rs:18:14
5751
|
5852
LL | let _x = 1/(false as u32);
5953
| ^^^^^^^^^^^^^^^^
6054

6155
error: this expression will panic at runtime
62-
--> $DIR/promoted_errors.rs:19:14
56+
--> $DIR/promoted_errors.rs:18:14
6357
|
6458
LL | let _x = 1/(false as u32);
6559
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
6660

67-
error: aborting due to 10 previous errors
61+
error: aborting due to 9 previous errors
6862

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// compile-flags: -C overflow-checks=on -O
2+
3+
#![deny(const_err)]
4+
5+
fn main() {
6+
println!("{}", 0u32 - 1);
7+
//~^ ERROR attempt to subtract with overflow
8+
let _x = 0u32 - 1;
9+
//~^ ERROR attempt to subtract with overflow
10+
println!("{}", 1/(1-1));
11+
//~^ ERROR attempt to divide by zero [const_err]
12+
//~| ERROR reaching this expression at runtime will panic or abort [const_err]
13+
let _x = 1/(1-1);
14+
//~^ ERROR const_err
15+
//~| ERROR const_err
16+
println!("{}", 1/(false as u32));
17+
//~^ ERROR attempt to divide by zero [const_err]
18+
//~| ERROR reaching this expression at runtime will panic or abort [const_err]
19+
let _x = 1/(false as u32);
20+
//~^ ERROR const_err
21+
//~| ERROR const_err
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
error: attempt to subtract with overflow
2+
--> $DIR/promoted_errors2.rs:6:20
3+
|
4+
LL | println!("{}", 0u32 - 1);
5+
| ^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/promoted_errors2.rs:3:9
9+
|
10+
LL | #![deny(const_err)]
11+
| ^^^^^^^^^
12+
13+
error: attempt to subtract with overflow
14+
--> $DIR/promoted_errors2.rs:8:14
15+
|
16+
LL | let _x = 0u32 - 1;
17+
| ^^^^^^^^
18+
19+
error: attempt to divide by zero
20+
--> $DIR/promoted_errors2.rs:10:20
21+
|
22+
LL | println!("{}", 1/(1-1));
23+
| ^^^^^^^
24+
25+
error: reaching this expression at runtime will panic or abort
26+
--> $DIR/promoted_errors2.rs:10:20
27+
|
28+
LL | println!("{}", 1/(1-1));
29+
| ^^^^^^^ attempt to divide by zero
30+
31+
error: attempt to divide by zero
32+
--> $DIR/promoted_errors2.rs:13:14
33+
|
34+
LL | let _x = 1/(1-1);
35+
| ^^^^^^^
36+
37+
error: this expression will panic at runtime
38+
--> $DIR/promoted_errors2.rs:13:14
39+
|
40+
LL | let _x = 1/(1-1);
41+
| ^^^^^^^ attempt to divide by zero
42+
43+
error: attempt to divide by zero
44+
--> $DIR/promoted_errors2.rs:16:20
45+
|
46+
LL | println!("{}", 1/(false as u32));
47+
| ^^^^^^^^^^^^^^^^
48+
49+
error: reaching this expression at runtime will panic or abort
50+
--> $DIR/promoted_errors2.rs:16:20
51+
|
52+
LL | println!("{}", 1/(false as u32));
53+
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
54+
55+
error: attempt to divide by zero
56+
--> $DIR/promoted_errors2.rs:19:14
57+
|
58+
LL | let _x = 1/(false as u32);
59+
| ^^^^^^^^^^^^^^^^
60+
61+
error: this expression will panic at runtime
62+
--> $DIR/promoted_errors2.rs:19:14
63+
|
64+
LL | let _x = 1/(false as u32);
65+
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
66+
67+
error: aborting due to 10 previous errors
68+

‎src/test/ui/consts/issue-64059-2.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// compile-flags: -C overflow-checks=on -O
2+
// run-pass
3+
4+
fn main() {
5+
let _ = -(-0.0);
6+
}

‎src/test/ui/consts/issue-64059.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// compile-flags: -C overflow-checks=on -O
21
// run-pass
32

43
fn main() {

‎src/test/ui/issues/issue-8460-const.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -C overflow-checks=on -O
2-
31
#![deny(const_err)]
42

53
use std::{isize, i8, i16, i32, i64};
@@ -8,14 +6,19 @@ use std::thread;
86
fn main() {
97
assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
108
//~^ ERROR attempt to divide with overflow
9+
//~| ERROR this expression will panic at runtime
1110
assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
1211
//~^ ERROR attempt to divide with overflow
12+
//~| ERROR this expression will panic at runtime
1313
assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
1414
//~^ ERROR attempt to divide with overflow
15+
//~| ERROR this expression will panic at runtime
1516
assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
1617
//~^ ERROR attempt to divide with overflow
18+
//~| ERROR this expression will panic at runtime
1719
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
1820
//~^ ERROR attempt to divide with overflow
21+
//~| ERROR this expression will panic at runtime
1922
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
2023
//~^ ERROR attempt to divide by zero
2124
//~| ERROR this expression will panic at runtime
@@ -33,14 +36,19 @@ fn main() {
3336
//~| ERROR this expression will panic at runtime
3437
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
3538
//~^ ERROR attempt to calculate the remainder with overflow
39+
//~| ERROR this expression will panic at runtime
3640
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
3741
//~^ ERROR attempt to calculate the remainder with overflow
42+
//~| ERROR this expression will panic at runtime
3843
assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
3944
//~^ ERROR attempt to calculate the remainder with overflow
45+
//~| ERROR this expression will panic at runtime
4046
assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
4147
//~^ ERROR attempt to calculate the remainder with overflow
48+
//~| ERROR this expression will panic at runtime
4249
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
4350
//~^ ERROR attempt to calculate the remainder with overflow
51+
//~| ERROR this expression will panic at runtime
4452
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
4553
//~^ ERROR attempt to calculate the remainder with a divisor of zero
4654
//~| ERROR this expression will panic at runtime

0 commit comments

Comments
 (0)
Please sign in to comment.