Skip to content

Commit 9c76394

Browse files
committed
more revisions and use them for another test
1 parent bd48522 commit 9c76394

11 files changed

+282
-13
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
error: this arithmetic operation will overflow
2+
--> $DIR/const-err2.rs:19:13
3+
|
4+
LL | let a = -std::i8::MIN;
5+
| ^^^^^^^^^^^^^ attempt to negate with overflow
6+
|
7+
= note: `#[deny(overflow)]` on by default
8+
9+
error: this arithmetic operation will overflow
10+
--> $DIR/const-err2.rs:21:18
11+
|
12+
LL | let a_i128 = -std::i128::MIN;
13+
| ^^^^^^^^^^^^^^^ attempt to negate with overflow
14+
15+
error: this arithmetic operation will overflow
16+
--> $DIR/const-err2.rs:23:13
17+
|
18+
LL | let b = 200u8 + 200u8 + 200u8;
19+
| ^^^^^^^^^^^^^ attempt to add with overflow
20+
21+
error: this arithmetic operation will overflow
22+
--> $DIR/const-err2.rs:25:18
23+
|
24+
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
26+
27+
error: this arithmetic operation will overflow
28+
--> $DIR/const-err2.rs:27:13
29+
|
30+
LL | let c = 200u8 * 4;
31+
| ^^^^^^^^^ attempt to multiply with overflow
32+
33+
error: this arithmetic operation will overflow
34+
--> $DIR/const-err2.rs:29:13
35+
|
36+
LL | let d = 42u8 - (42u8 + 1);
37+
| ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
38+
39+
error: this operation will panic at runtime
40+
--> $DIR/const-err2.rs:31:14
41+
|
42+
LL | let _e = [5u8][1];
43+
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
44+
|
45+
= note: `#[deny(panic)]` on by default
46+
47+
error: aborting due to 7 previous errors
48+

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// optimized compilation and unoptimized compilation and thus would
33
// lead to different lints being emitted
44

5-
// revisions: debug opt opt_with_overflow_checks
6-
//[debug]compile-flags: -C opt-level=0
5+
// revisions: default noopt opt opt_with_overflow_checks
6+
//[noopt]compile-flags: -C opt-level=0
77
//[opt]compile-flags: -O
88
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
99

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
warning: this arithmetic operation will overflow
2+
--> $DIR/promoted_errors.rs:14:14
3+
|
4+
LL | let _x = 0u32 - 1;
5+
| ^^^^^^^^ attempt to subtract with overflow
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/promoted_errors.rs:9:20
9+
|
10+
LL | #![warn(const_err, overflow, panic)]
11+
| ^^^^^^^^
12+
13+
warning: this operation will panic at runtime
14+
--> $DIR/promoted_errors.rs:16:20
15+
|
16+
LL | println!("{}", 1 / (1 - 1));
17+
| ^^^^^^^^^^^ attempt to divide by zero
18+
|
19+
note: the lint level is defined here
20+
--> $DIR/promoted_errors.rs:9:30
21+
|
22+
LL | #![warn(const_err, overflow, panic)]
23+
| ^^^^^
24+
25+
warning: reaching this expression at runtime will panic or abort
26+
--> $DIR/promoted_errors.rs:16:20
27+
|
28+
LL | println!("{}", 1 / (1 - 1));
29+
| ^^^^^^^^^^^ dividing by zero
30+
|
31+
note: the lint level is defined here
32+
--> $DIR/promoted_errors.rs:9:9
33+
|
34+
LL | #![warn(const_err, overflow, panic)]
35+
| ^^^^^^^^^
36+
37+
warning: erroneous constant used
38+
--> $DIR/promoted_errors.rs:16:20
39+
|
40+
LL | println!("{}", 1 / (1 - 1));
41+
| ^^^^^^^^^^^ referenced constant has errors
42+
43+
warning: this operation will panic at runtime
44+
--> $DIR/promoted_errors.rs:20:14
45+
|
46+
LL | let _x = 1 / (1 - 1);
47+
| ^^^^^^^^^^^ attempt to divide by zero
48+
49+
warning: this operation will panic at runtime
50+
--> $DIR/promoted_errors.rs:22:20
51+
|
52+
LL | println!("{}", 1 / (false as u32));
53+
| ^^^^^^^^^^^^^^^^^^ attempt to divide by zero
54+
55+
warning: reaching this expression at runtime will panic or abort
56+
--> $DIR/promoted_errors.rs:22:20
57+
|
58+
LL | println!("{}", 1 / (false as u32));
59+
| ^^^^^^^^^^^^^^^^^^ dividing by zero
60+
61+
warning: erroneous constant used
62+
--> $DIR/promoted_errors.rs:22:20
63+
|
64+
LL | println!("{}", 1 / (false as u32));
65+
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
66+
67+
warning: this operation will panic at runtime
68+
--> $DIR/promoted_errors.rs:26:14
69+
|
70+
LL | let _x = 1 / (false as u32);
71+
| ^^^^^^^^^^^^^^^^^^ attempt to divide by zero
72+

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// revisions: debug opt opt_with_overflow_checks
2-
//[debug]compile-flags: -C opt-level=0
1+
// revisions: default noopt opt opt_with_overflow_checks
2+
//[noopt]compile-flags: -C opt-level=0
33
//[opt]compile-flags: -O
44
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
55

@@ -10,7 +10,7 @@
1010

1111
fn main() {
1212
println!("{}", 0u32 - 1);
13-
//[opt_with_overflow_checks,debug]~^ WARN [overflow]
13+
//[opt_with_overflow_checks,noopt]~^ WARN [overflow]
1414
let _x = 0u32 - 1;
1515
//~^ WARN [overflow]
1616
println!("{}", 1 / (1 - 1));

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

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// revisions: default noopt opt opt_with_overflow_checks
2+
//[noopt]compile-flags: -C opt-level=0
3+
//[opt]compile-flags: -O
4+
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
5+
16
// run-pass
27

38
fn main() {
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
error: this arithmetic operation will overflow
2+
--> $DIR/issue-8460-const.rs:14:36
3+
|
4+
LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
5+
| ^^^^^^^^^^^^^^^ attempt to divide with overflow
6+
|
7+
= note: `#[deny(overflow)]` on by default
8+
9+
error: this arithmetic operation will overflow
10+
--> $DIR/issue-8460-const.rs:16:36
11+
|
12+
LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
13+
| ^^^^^^^^^^^^ attempt to divide with overflow
14+
15+
error: this arithmetic operation will overflow
16+
--> $DIR/issue-8460-const.rs:18:36
17+
|
18+
LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
19+
| ^^^^^^^^^^^^^ attempt to divide with overflow
20+
21+
error: this arithmetic operation will overflow
22+
--> $DIR/issue-8460-const.rs:20:36
23+
|
24+
LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
25+
| ^^^^^^^^^^^^^ attempt to divide with overflow
26+
27+
error: this arithmetic operation will overflow
28+
--> $DIR/issue-8460-const.rs:22:36
29+
|
30+
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
31+
| ^^^^^^^^^^^^^ attempt to divide with overflow
32+
33+
error: this arithmetic operation will overflow
34+
--> $DIR/issue-8460-const.rs:24:36
35+
|
36+
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
37+
| ^^^^^^^^^^^^^^ attempt to divide with overflow
38+
39+
error: this operation will panic at runtime
40+
--> $DIR/issue-8460-const.rs:26:36
41+
|
42+
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
43+
| ^^^^^^^^^^ attempt to divide by zero
44+
|
45+
= note: `#[deny(panic)]` on by default
46+
47+
error: this operation will panic at runtime
48+
--> $DIR/issue-8460-const.rs:28:36
49+
|
50+
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
51+
| ^^^^^^^ attempt to divide by zero
52+
53+
error: this operation will panic at runtime
54+
--> $DIR/issue-8460-const.rs:30:36
55+
|
56+
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
57+
| ^^^^^^^^ attempt to divide by zero
58+
59+
error: this operation will panic at runtime
60+
--> $DIR/issue-8460-const.rs:32:36
61+
|
62+
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
63+
| ^^^^^^^^ attempt to divide by zero
64+
65+
error: this operation will panic at runtime
66+
--> $DIR/issue-8460-const.rs:34:36
67+
|
68+
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
69+
| ^^^^^^^^ attempt to divide by zero
70+
71+
error: this operation will panic at runtime
72+
--> $DIR/issue-8460-const.rs:36:36
73+
|
74+
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
75+
| ^^^^^^^^^ attempt to divide by zero
76+
77+
error: this arithmetic operation will overflow
78+
--> $DIR/issue-8460-const.rs:38:36
79+
|
80+
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
81+
| ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
82+
83+
error: this arithmetic operation will overflow
84+
--> $DIR/issue-8460-const.rs:40:36
85+
|
86+
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
87+
| ^^^^^^^^^^^^ attempt to calculate the remainder with overflow
88+
89+
error: this arithmetic operation will overflow
90+
--> $DIR/issue-8460-const.rs:42:36
91+
|
92+
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
93+
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
94+
95+
error: this arithmetic operation will overflow
96+
--> $DIR/issue-8460-const.rs:44:36
97+
|
98+
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
99+
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
100+
101+
error: this arithmetic operation will overflow
102+
--> $DIR/issue-8460-const.rs:46:36
103+
|
104+
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
105+
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
106+
107+
error: this arithmetic operation will overflow
108+
--> $DIR/issue-8460-const.rs:48:36
109+
|
110+
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
111+
| ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
112+
113+
error: this operation will panic at runtime
114+
--> $DIR/issue-8460-const.rs:50:36
115+
|
116+
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
117+
| ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero
118+
119+
error: this operation will panic at runtime
120+
--> $DIR/issue-8460-const.rs:52:36
121+
|
122+
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
123+
| ^^^^^^^ attempt to calculate the remainder with a divisor of zero
124+
125+
error: this operation will panic at runtime
126+
--> $DIR/issue-8460-const.rs:54:36
127+
|
128+
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
129+
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
130+
131+
error: this operation will panic at runtime
132+
--> $DIR/issue-8460-const.rs:56:36
133+
|
134+
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
135+
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
136+
137+
error: this operation will panic at runtime
138+
--> $DIR/issue-8460-const.rs:58:36
139+
|
140+
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
141+
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
142+
143+
error: this operation will panic at runtime
144+
--> $DIR/issue-8460-const.rs:60:36
145+
|
146+
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
147+
| ^^^^^^^^^ attempt to calculate the remainder with a divisor of zero
148+
149+
error: aborting due to 24 previous errors
150+

0 commit comments

Comments
 (0)