Skip to content

Commit 33500a2

Browse files
authoredApr 16, 2020
Rollup merge of rust-lang#70566 - jumbatm:exceeding-bitshifts-constprop, r=RalfJung
Don't bail out before linting in generic contexts. Fixes rust-lang#69021. cc rust-lang#70017 r? @RalfJung
2 parents 4e4d49d + ed73023 commit 33500a2

5 files changed

+133
-115
lines changed
 

‎src/librustc_mir/transform/const_prop.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
581581
return None;
582582
}
583583

584-
// FIXME we need to revisit this for #67176
585-
if rvalue.needs_subst() {
586-
return None;
587-
}
588-
589584
// Perform any special handling for specific Rvalue types.
590585
// Generally, checks here fall into one of two categories:
591586
// 1. Additional checking to provide useful lints to the user
@@ -626,6 +621,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
626621
_ => {}
627622
}
628623

624+
// FIXME we need to revisit this for #67176
625+
if rvalue.needs_subst() {
626+
return None;
627+
}
628+
629629
self.use_ecx(|this| {
630630
trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place);
631631
this.ecx.eval_rvalue_into_place(rvalue, place)?;
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,152 @@
1-
error: this arithmetic operation will overflow
2-
--> $DIR/lint-exceeding-bitshifts.rs:22:13
1+
warning: this arithmetic operation will overflow
2+
--> $DIR/lint-exceeding-bitshifts.rs:18:20
33
|
4-
LL | let _ = x << 42;
5-
| ^^^^^^^ attempt to shift left with overflow
4+
LL | const N: i32 = T::N << 42;
5+
| ^^^^^^^^^^ attempt to shift left with overflow
66
|
77
note: the lint level is defined here
88
--> $DIR/lint-exceeding-bitshifts.rs:9:9
99
|
10-
LL | #![deny(arithmetic_overflow, const_err)]
10+
LL | #![warn(arithmetic_overflow, const_err)]
1111
| ^^^^^^^^^^^^^^^^^^^
1212

13-
error: this arithmetic operation will overflow
13+
warning: this arithmetic operation will overflow
14+
--> $DIR/lint-exceeding-bitshifts.rs:22:13
15+
|
16+
LL | let _ = x << 42;
17+
| ^^^^^^^ attempt to shift left with overflow
18+
19+
warning: this arithmetic operation will overflow
1420
--> $DIR/lint-exceeding-bitshifts.rs:27:15
1521
|
1622
LL | let n = 1u8 << 8;
1723
| ^^^^^^^^ attempt to shift left with overflow
1824

19-
error: this arithmetic operation will overflow
25+
warning: this arithmetic operation will overflow
2026
--> $DIR/lint-exceeding-bitshifts.rs:29:15
2127
|
2228
LL | let n = 1u16 << 16;
2329
| ^^^^^^^^^^ attempt to shift left with overflow
2430

25-
error: this arithmetic operation will overflow
31+
warning: this arithmetic operation will overflow
2632
--> $DIR/lint-exceeding-bitshifts.rs:31:15
2733
|
2834
LL | let n = 1u32 << 32;
2935
| ^^^^^^^^^^ attempt to shift left with overflow
3036

31-
error: this arithmetic operation will overflow
37+
warning: this arithmetic operation will overflow
3238
--> $DIR/lint-exceeding-bitshifts.rs:33:15
3339
|
3440
LL | let n = 1u64 << 64;
3541
| ^^^^^^^^^^ attempt to shift left with overflow
3642

37-
error: this arithmetic operation will overflow
43+
warning: this arithmetic operation will overflow
3844
--> $DIR/lint-exceeding-bitshifts.rs:35:15
3945
|
4046
LL | let n = 1i8 << 8;
4147
| ^^^^^^^^ attempt to shift left with overflow
4248

43-
error: this arithmetic operation will overflow
49+
warning: this arithmetic operation will overflow
4450
--> $DIR/lint-exceeding-bitshifts.rs:37:15
4551
|
4652
LL | let n = 1i16 << 16;
4753
| ^^^^^^^^^^ attempt to shift left with overflow
4854

49-
error: this arithmetic operation will overflow
55+
warning: this arithmetic operation will overflow
5056
--> $DIR/lint-exceeding-bitshifts.rs:39:15
5157
|
5258
LL | let n = 1i32 << 32;
5359
| ^^^^^^^^^^ attempt to shift left with overflow
5460

55-
error: this arithmetic operation will overflow
61+
warning: this arithmetic operation will overflow
5662
--> $DIR/lint-exceeding-bitshifts.rs:41:15
5763
|
5864
LL | let n = 1i64 << 64;
5965
| ^^^^^^^^^^ attempt to shift left with overflow
6066

61-
error: this arithmetic operation will overflow
67+
warning: this arithmetic operation will overflow
6268
--> $DIR/lint-exceeding-bitshifts.rs:44:15
6369
|
6470
LL | let n = 1u8 >> 8;
6571
| ^^^^^^^^ attempt to shift right with overflow
6672

67-
error: this arithmetic operation will overflow
73+
warning: this arithmetic operation will overflow
6874
--> $DIR/lint-exceeding-bitshifts.rs:46:15
6975
|
7076
LL | let n = 1u16 >> 16;
7177
| ^^^^^^^^^^ attempt to shift right with overflow
7278

73-
error: this arithmetic operation will overflow
79+
warning: this arithmetic operation will overflow
7480
--> $DIR/lint-exceeding-bitshifts.rs:48:15
7581
|
7682
LL | let n = 1u32 >> 32;
7783
| ^^^^^^^^^^ attempt to shift right with overflow
7884

79-
error: this arithmetic operation will overflow
85+
warning: this arithmetic operation will overflow
8086
--> $DIR/lint-exceeding-bitshifts.rs:50:15
8187
|
8288
LL | let n = 1u64 >> 64;
8389
| ^^^^^^^^^^ attempt to shift right with overflow
8490

85-
error: this arithmetic operation will overflow
91+
warning: this arithmetic operation will overflow
8692
--> $DIR/lint-exceeding-bitshifts.rs:52:15
8793
|
8894
LL | let n = 1i8 >> 8;
8995
| ^^^^^^^^ attempt to shift right with overflow
9096

91-
error: this arithmetic operation will overflow
97+
warning: this arithmetic operation will overflow
9298
--> $DIR/lint-exceeding-bitshifts.rs:54:15
9399
|
94100
LL | let n = 1i16 >> 16;
95101
| ^^^^^^^^^^ attempt to shift right with overflow
96102

97-
error: this arithmetic operation will overflow
103+
warning: this arithmetic operation will overflow
98104
--> $DIR/lint-exceeding-bitshifts.rs:56:15
99105
|
100106
LL | let n = 1i32 >> 32;
101107
| ^^^^^^^^^^ attempt to shift right with overflow
102108

103-
error: this arithmetic operation will overflow
109+
warning: this arithmetic operation will overflow
104110
--> $DIR/lint-exceeding-bitshifts.rs:58:15
105111
|
106112
LL | let n = 1i64 >> 64;
107113
| ^^^^^^^^^^ attempt to shift right with overflow
108114

109-
error: this arithmetic operation will overflow
115+
warning: this arithmetic operation will overflow
110116
--> $DIR/lint-exceeding-bitshifts.rs:62:15
111117
|
112118
LL | let n = n << 8;
113119
| ^^^^^^ attempt to shift left with overflow
114120

115-
error: this arithmetic operation will overflow
121+
warning: this arithmetic operation will overflow
116122
--> $DIR/lint-exceeding-bitshifts.rs:64:15
117123
|
118124
LL | let n = 1u8 << -8;
119125
| ^^^^^^^^^ attempt to shift left with overflow
120126

121-
error: this arithmetic operation will overflow
127+
warning: this arithmetic operation will overflow
122128
--> $DIR/lint-exceeding-bitshifts.rs:69:15
123129
|
124130
LL | let n = 1u8 << (4+4);
125131
| ^^^^^^^^^^^^ attempt to shift left with overflow
126132

127-
error: this arithmetic operation will overflow
133+
warning: this arithmetic operation will overflow
128134
--> $DIR/lint-exceeding-bitshifts.rs:71:15
129135
|
130136
LL | let n = 1i64 >> [64][0];
131137
| ^^^^^^^^^^^^^^^ attempt to shift right with overflow
132138

133-
error: this arithmetic operation will overflow
139+
warning: this arithmetic operation will overflow
134140
--> $DIR/lint-exceeding-bitshifts.rs:77:15
135141
|
136142
LL | let n = 1_isize << BITS;
137143
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
138144

139-
error: this arithmetic operation will overflow
145+
warning: this arithmetic operation will overflow
140146
--> $DIR/lint-exceeding-bitshifts.rs:78:15
141147
|
142148
LL | let n = 1_usize << BITS;
143149
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
144150

145-
error: aborting due to 23 previous errors
151+
warning: 24 warnings emitted
146152

Original file line numberDiff line numberDiff line change
@@ -1,146 +1,152 @@
1-
error: this arithmetic operation will overflow
2-
--> $DIR/lint-exceeding-bitshifts.rs:22:13
1+
warning: this arithmetic operation will overflow
2+
--> $DIR/lint-exceeding-bitshifts.rs:18:20
33
|
4-
LL | let _ = x << 42;
5-
| ^^^^^^^ attempt to shift left with overflow
4+
LL | const N: i32 = T::N << 42;
5+
| ^^^^^^^^^^ attempt to shift left with overflow
66
|
77
note: the lint level is defined here
88
--> $DIR/lint-exceeding-bitshifts.rs:9:9
99
|
10-
LL | #![deny(arithmetic_overflow, const_err)]
10+
LL | #![warn(arithmetic_overflow, const_err)]
1111
| ^^^^^^^^^^^^^^^^^^^
1212

13-
error: this arithmetic operation will overflow
13+
warning: this arithmetic operation will overflow
14+
--> $DIR/lint-exceeding-bitshifts.rs:22:13
15+
|
16+
LL | let _ = x << 42;
17+
| ^^^^^^^ attempt to shift left with overflow
18+
19+
warning: this arithmetic operation will overflow
1420
--> $DIR/lint-exceeding-bitshifts.rs:27:15
1521
|
1622
LL | let n = 1u8 << 8;
1723
| ^^^^^^^^ attempt to shift left with overflow
1824

19-
error: this arithmetic operation will overflow
25+
warning: this arithmetic operation will overflow
2026
--> $DIR/lint-exceeding-bitshifts.rs:29:15
2127
|
2228
LL | let n = 1u16 << 16;
2329
| ^^^^^^^^^^ attempt to shift left with overflow
2430

25-
error: this arithmetic operation will overflow
31+
warning: this arithmetic operation will overflow
2632
--> $DIR/lint-exceeding-bitshifts.rs:31:15
2733
|
2834
LL | let n = 1u32 << 32;
2935
| ^^^^^^^^^^ attempt to shift left with overflow
3036

31-
error: this arithmetic operation will overflow
37+
warning: this arithmetic operation will overflow
3238
--> $DIR/lint-exceeding-bitshifts.rs:33:15
3339
|
3440
LL | let n = 1u64 << 64;
3541
| ^^^^^^^^^^ attempt to shift left with overflow
3642

37-
error: this arithmetic operation will overflow
43+
warning: this arithmetic operation will overflow
3844
--> $DIR/lint-exceeding-bitshifts.rs:35:15
3945
|
4046
LL | let n = 1i8 << 8;
4147
| ^^^^^^^^ attempt to shift left with overflow
4248

43-
error: this arithmetic operation will overflow
49+
warning: this arithmetic operation will overflow
4450
--> $DIR/lint-exceeding-bitshifts.rs:37:15
4551
|
4652
LL | let n = 1i16 << 16;
4753
| ^^^^^^^^^^ attempt to shift left with overflow
4854

49-
error: this arithmetic operation will overflow
55+
warning: this arithmetic operation will overflow
5056
--> $DIR/lint-exceeding-bitshifts.rs:39:15
5157
|
5258
LL | let n = 1i32 << 32;
5359
| ^^^^^^^^^^ attempt to shift left with overflow
5460

55-
error: this arithmetic operation will overflow
61+
warning: this arithmetic operation will overflow
5662
--> $DIR/lint-exceeding-bitshifts.rs:41:15
5763
|
5864
LL | let n = 1i64 << 64;
5965
| ^^^^^^^^^^ attempt to shift left with overflow
6066

61-
error: this arithmetic operation will overflow
67+
warning: this arithmetic operation will overflow
6268
--> $DIR/lint-exceeding-bitshifts.rs:44:15
6369
|
6470
LL | let n = 1u8 >> 8;
6571
| ^^^^^^^^ attempt to shift right with overflow
6672

67-
error: this arithmetic operation will overflow
73+
warning: this arithmetic operation will overflow
6874
--> $DIR/lint-exceeding-bitshifts.rs:46:15
6975
|
7076
LL | let n = 1u16 >> 16;
7177
| ^^^^^^^^^^ attempt to shift right with overflow
7278

73-
error: this arithmetic operation will overflow
79+
warning: this arithmetic operation will overflow
7480
--> $DIR/lint-exceeding-bitshifts.rs:48:15
7581
|
7682
LL | let n = 1u32 >> 32;
7783
| ^^^^^^^^^^ attempt to shift right with overflow
7884

79-
error: this arithmetic operation will overflow
85+
warning: this arithmetic operation will overflow
8086
--> $DIR/lint-exceeding-bitshifts.rs:50:15
8187
|
8288
LL | let n = 1u64 >> 64;
8389
| ^^^^^^^^^^ attempt to shift right with overflow
8490

85-
error: this arithmetic operation will overflow
91+
warning: this arithmetic operation will overflow
8692
--> $DIR/lint-exceeding-bitshifts.rs:52:15
8793
|
8894
LL | let n = 1i8 >> 8;
8995
| ^^^^^^^^ attempt to shift right with overflow
9096

91-
error: this arithmetic operation will overflow
97+
warning: this arithmetic operation will overflow
9298
--> $DIR/lint-exceeding-bitshifts.rs:54:15
9399
|
94100
LL | let n = 1i16 >> 16;
95101
| ^^^^^^^^^^ attempt to shift right with overflow
96102

97-
error: this arithmetic operation will overflow
103+
warning: this arithmetic operation will overflow
98104
--> $DIR/lint-exceeding-bitshifts.rs:56:15
99105
|
100106
LL | let n = 1i32 >> 32;
101107
| ^^^^^^^^^^ attempt to shift right with overflow
102108

103-
error: this arithmetic operation will overflow
109+
warning: this arithmetic operation will overflow
104110
--> $DIR/lint-exceeding-bitshifts.rs:58:15
105111
|
106112
LL | let n = 1i64 >> 64;
107113
| ^^^^^^^^^^ attempt to shift right with overflow
108114

109-
error: this arithmetic operation will overflow
115+
warning: this arithmetic operation will overflow
110116
--> $DIR/lint-exceeding-bitshifts.rs:62:15
111117
|
112118
LL | let n = n << 8;
113119
| ^^^^^^ attempt to shift left with overflow
114120

115-
error: this arithmetic operation will overflow
121+
warning: this arithmetic operation will overflow
116122
--> $DIR/lint-exceeding-bitshifts.rs:64:15
117123
|
118124
LL | let n = 1u8 << -8;
119125
| ^^^^^^^^^ attempt to shift left with overflow
120126

121-
error: this arithmetic operation will overflow
127+
warning: this arithmetic operation will overflow
122128
--> $DIR/lint-exceeding-bitshifts.rs:69:15
123129
|
124130
LL | let n = 1u8 << (4+4);
125131
| ^^^^^^^^^^^^ attempt to shift left with overflow
126132

127-
error: this arithmetic operation will overflow
133+
warning: this arithmetic operation will overflow
128134
--> $DIR/lint-exceeding-bitshifts.rs:71:15
129135
|
130136
LL | let n = 1i64 >> [64][0];
131137
| ^^^^^^^^^^^^^^^ attempt to shift right with overflow
132138

133-
error: this arithmetic operation will overflow
139+
warning: this arithmetic operation will overflow
134140
--> $DIR/lint-exceeding-bitshifts.rs:77:15
135141
|
136142
LL | let n = 1_isize << BITS;
137143
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
138144

139-
error: this arithmetic operation will overflow
145+
warning: this arithmetic operation will overflow
140146
--> $DIR/lint-exceeding-bitshifts.rs:78:15
141147
|
142148
LL | let n = 1_usize << BITS;
143149
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
144150

145-
error: aborting due to 23 previous errors
151+
warning: 24 warnings emitted
146152

Original file line numberDiff line numberDiff line change
@@ -1,146 +1,152 @@
1-
error: this arithmetic operation will overflow
2-
--> $DIR/lint-exceeding-bitshifts.rs:22:13
1+
warning: this arithmetic operation will overflow
2+
--> $DIR/lint-exceeding-bitshifts.rs:18:20
33
|
4-
LL | let _ = x << 42;
5-
| ^^^^^^^ attempt to shift left with overflow
4+
LL | const N: i32 = T::N << 42;
5+
| ^^^^^^^^^^ attempt to shift left with overflow
66
|
77
note: the lint level is defined here
88
--> $DIR/lint-exceeding-bitshifts.rs:9:9
99
|
10-
LL | #![deny(arithmetic_overflow, const_err)]
10+
LL | #![warn(arithmetic_overflow, const_err)]
1111
| ^^^^^^^^^^^^^^^^^^^
1212

13-
error: this arithmetic operation will overflow
13+
warning: this arithmetic operation will overflow
14+
--> $DIR/lint-exceeding-bitshifts.rs:22:13
15+
|
16+
LL | let _ = x << 42;
17+
| ^^^^^^^ attempt to shift left with overflow
18+
19+
warning: this arithmetic operation will overflow
1420
--> $DIR/lint-exceeding-bitshifts.rs:27:15
1521
|
1622
LL | let n = 1u8 << 8;
1723
| ^^^^^^^^ attempt to shift left with overflow
1824

19-
error: this arithmetic operation will overflow
25+
warning: this arithmetic operation will overflow
2026
--> $DIR/lint-exceeding-bitshifts.rs:29:15
2127
|
2228
LL | let n = 1u16 << 16;
2329
| ^^^^^^^^^^ attempt to shift left with overflow
2430

25-
error: this arithmetic operation will overflow
31+
warning: this arithmetic operation will overflow
2632
--> $DIR/lint-exceeding-bitshifts.rs:31:15
2733
|
2834
LL | let n = 1u32 << 32;
2935
| ^^^^^^^^^^ attempt to shift left with overflow
3036

31-
error: this arithmetic operation will overflow
37+
warning: this arithmetic operation will overflow
3238
--> $DIR/lint-exceeding-bitshifts.rs:33:15
3339
|
3440
LL | let n = 1u64 << 64;
3541
| ^^^^^^^^^^ attempt to shift left with overflow
3642

37-
error: this arithmetic operation will overflow
43+
warning: this arithmetic operation will overflow
3844
--> $DIR/lint-exceeding-bitshifts.rs:35:15
3945
|
4046
LL | let n = 1i8 << 8;
4147
| ^^^^^^^^ attempt to shift left with overflow
4248

43-
error: this arithmetic operation will overflow
49+
warning: this arithmetic operation will overflow
4450
--> $DIR/lint-exceeding-bitshifts.rs:37:15
4551
|
4652
LL | let n = 1i16 << 16;
4753
| ^^^^^^^^^^ attempt to shift left with overflow
4854

49-
error: this arithmetic operation will overflow
55+
warning: this arithmetic operation will overflow
5056
--> $DIR/lint-exceeding-bitshifts.rs:39:15
5157
|
5258
LL | let n = 1i32 << 32;
5359
| ^^^^^^^^^^ attempt to shift left with overflow
5460

55-
error: this arithmetic operation will overflow
61+
warning: this arithmetic operation will overflow
5662
--> $DIR/lint-exceeding-bitshifts.rs:41:15
5763
|
5864
LL | let n = 1i64 << 64;
5965
| ^^^^^^^^^^ attempt to shift left with overflow
6066

61-
error: this arithmetic operation will overflow
67+
warning: this arithmetic operation will overflow
6268
--> $DIR/lint-exceeding-bitshifts.rs:44:15
6369
|
6470
LL | let n = 1u8 >> 8;
6571
| ^^^^^^^^ attempt to shift right with overflow
6672

67-
error: this arithmetic operation will overflow
73+
warning: this arithmetic operation will overflow
6874
--> $DIR/lint-exceeding-bitshifts.rs:46:15
6975
|
7076
LL | let n = 1u16 >> 16;
7177
| ^^^^^^^^^^ attempt to shift right with overflow
7278

73-
error: this arithmetic operation will overflow
79+
warning: this arithmetic operation will overflow
7480
--> $DIR/lint-exceeding-bitshifts.rs:48:15
7581
|
7682
LL | let n = 1u32 >> 32;
7783
| ^^^^^^^^^^ attempt to shift right with overflow
7884

79-
error: this arithmetic operation will overflow
85+
warning: this arithmetic operation will overflow
8086
--> $DIR/lint-exceeding-bitshifts.rs:50:15
8187
|
8288
LL | let n = 1u64 >> 64;
8389
| ^^^^^^^^^^ attempt to shift right with overflow
8490

85-
error: this arithmetic operation will overflow
91+
warning: this arithmetic operation will overflow
8692
--> $DIR/lint-exceeding-bitshifts.rs:52:15
8793
|
8894
LL | let n = 1i8 >> 8;
8995
| ^^^^^^^^ attempt to shift right with overflow
9096

91-
error: this arithmetic operation will overflow
97+
warning: this arithmetic operation will overflow
9298
--> $DIR/lint-exceeding-bitshifts.rs:54:15
9399
|
94100
LL | let n = 1i16 >> 16;
95101
| ^^^^^^^^^^ attempt to shift right with overflow
96102

97-
error: this arithmetic operation will overflow
103+
warning: this arithmetic operation will overflow
98104
--> $DIR/lint-exceeding-bitshifts.rs:56:15
99105
|
100106
LL | let n = 1i32 >> 32;
101107
| ^^^^^^^^^^ attempt to shift right with overflow
102108

103-
error: this arithmetic operation will overflow
109+
warning: this arithmetic operation will overflow
104110
--> $DIR/lint-exceeding-bitshifts.rs:58:15
105111
|
106112
LL | let n = 1i64 >> 64;
107113
| ^^^^^^^^^^ attempt to shift right with overflow
108114

109-
error: this arithmetic operation will overflow
115+
warning: this arithmetic operation will overflow
110116
--> $DIR/lint-exceeding-bitshifts.rs:62:15
111117
|
112118
LL | let n = n << 8;
113119
| ^^^^^^ attempt to shift left with overflow
114120

115-
error: this arithmetic operation will overflow
121+
warning: this arithmetic operation will overflow
116122
--> $DIR/lint-exceeding-bitshifts.rs:64:15
117123
|
118124
LL | let n = 1u8 << -8;
119125
| ^^^^^^^^^ attempt to shift left with overflow
120126

121-
error: this arithmetic operation will overflow
127+
warning: this arithmetic operation will overflow
122128
--> $DIR/lint-exceeding-bitshifts.rs:69:15
123129
|
124130
LL | let n = 1u8 << (4+4);
125131
| ^^^^^^^^^^^^ attempt to shift left with overflow
126132

127-
error: this arithmetic operation will overflow
133+
warning: this arithmetic operation will overflow
128134
--> $DIR/lint-exceeding-bitshifts.rs:71:15
129135
|
130136
LL | let n = 1i64 >> [64][0];
131137
| ^^^^^^^^^^^^^^^ attempt to shift right with overflow
132138

133-
error: this arithmetic operation will overflow
139+
warning: this arithmetic operation will overflow
134140
--> $DIR/lint-exceeding-bitshifts.rs:77:15
135141
|
136142
LL | let n = 1_isize << BITS;
137143
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
138144

139-
error: this arithmetic operation will overflow
145+
warning: this arithmetic operation will overflow
140146
--> $DIR/lint-exceeding-bitshifts.rs:78:15
141147
|
142148
LL | let n = 1_usize << BITS;
143149
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
144150

145-
error: aborting due to 23 previous errors
151+
warning: 24 warnings emitted
146152

‎src/test/ui/lint/lint-exceeding-bitshifts.rs

+26-26
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
//[opt]compile-flags: -O
44
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
55

6-
// build-fail
6+
// build-pass
77

88
#![crate_type="lib"]
9-
#![deny(arithmetic_overflow, const_err)]
9+
#![warn(arithmetic_overflow, const_err)]
1010
#![allow(unused_variables)]
1111
#![allow(dead_code)]
1212

@@ -15,65 +15,65 @@ pub trait Foo {
1515
}
1616

1717
impl<T: Foo> Foo for Vec<T> {
18-
const N: i32 = T::N << 42; // FIXME this should warn
18+
const N: i32 = T::N << 42; //~ WARN: arithmetic operation will overflow
1919
}
2020

2121
pub fn foo(x: i32) {
22-
let _ = x << 42; //~ ERROR: arithmetic operation will overflow
22+
let _ = x << 42; //~ WARN: arithmetic operation will overflow
2323
}
2424

2525
pub fn main() {
2626
let n = 1u8 << 7;
27-
let n = 1u8 << 8; //~ ERROR: arithmetic operation will overflow
27+
let n = 1u8 << 8; //~ WARN: arithmetic operation will overflow
2828
let n = 1u16 << 15;
29-
let n = 1u16 << 16; //~ ERROR: arithmetic operation will overflow
29+
let n = 1u16 << 16; //~ WARN: arithmetic operation will overflow
3030
let n = 1u32 << 31;
31-
let n = 1u32 << 32; //~ ERROR: arithmetic operation will overflow
31+
let n = 1u32 << 32; //~ WARN: arithmetic operation will overflow
3232
let n = 1u64 << 63;
33-
let n = 1u64 << 64; //~ ERROR: arithmetic operation will overflow
33+
let n = 1u64 << 64; //~ WARN: arithmetic operation will overflow
3434
let n = 1i8 << 7;
35-
let n = 1i8 << 8; //~ ERROR: arithmetic operation will overflow
35+
let n = 1i8 << 8; //~ WARN: arithmetic operation will overflow
3636
let n = 1i16 << 15;
37-
let n = 1i16 << 16; //~ ERROR: arithmetic operation will overflow
37+
let n = 1i16 << 16; //~ WARN: arithmetic operation will overflow
3838
let n = 1i32 << 31;
39-
let n = 1i32 << 32; //~ ERROR: arithmetic operation will overflow
39+
let n = 1i32 << 32; //~ WARN: arithmetic operation will overflow
4040
let n = 1i64 << 63;
41-
let n = 1i64 << 64; //~ ERROR: arithmetic operation will overflow
41+
let n = 1i64 << 64; //~ WARN: arithmetic operation will overflow
4242

4343
let n = 1u8 >> 7;
44-
let n = 1u8 >> 8; //~ ERROR: arithmetic operation will overflow
44+
let n = 1u8 >> 8; //~ WARN: arithmetic operation will overflow
4545
let n = 1u16 >> 15;
46-
let n = 1u16 >> 16; //~ ERROR: arithmetic operation will overflow
46+
let n = 1u16 >> 16; //~ WARN: arithmetic operation will overflow
4747
let n = 1u32 >> 31;
48-
let n = 1u32 >> 32; //~ ERROR: arithmetic operation will overflow
48+
let n = 1u32 >> 32; //~ WARN: arithmetic operation will overflow
4949
let n = 1u64 >> 63;
50-
let n = 1u64 >> 64; //~ ERROR: arithmetic operation will overflow
50+
let n = 1u64 >> 64; //~ WARN: arithmetic operation will overflow
5151
let n = 1i8 >> 7;
52-
let n = 1i8 >> 8; //~ ERROR: arithmetic operation will overflow
52+
let n = 1i8 >> 8; //~ WARN: arithmetic operation will overflow
5353
let n = 1i16 >> 15;
54-
let n = 1i16 >> 16; //~ ERROR: arithmetic operation will overflow
54+
let n = 1i16 >> 16; //~ WARN: arithmetic operation will overflow
5555
let n = 1i32 >> 31;
56-
let n = 1i32 >> 32; //~ ERROR: arithmetic operation will overflow
56+
let n = 1i32 >> 32; //~ WARN: arithmetic operation will overflow
5757
let n = 1i64 >> 63;
58-
let n = 1i64 >> 64; //~ ERROR: arithmetic operation will overflow
58+
let n = 1i64 >> 64; //~ WARN: arithmetic operation will overflow
5959

6060
let n = 1u8;
6161
let n = n << 7;
62-
let n = n << 8; //~ ERROR: arithmetic operation will overflow
62+
let n = n << 8; //~ WARN: arithmetic operation will overflow
6363

64-
let n = 1u8 << -8; //~ ERROR: arithmetic operation will overflow
64+
let n = 1u8 << -8; //~ WARN: arithmetic operation will overflow
6565

6666
let n = 1i8<<(1isize+-1);
6767

6868
let n = 1u8 << (4+3);
69-
let n = 1u8 << (4+4); //~ ERROR: arithmetic operation will overflow
69+
let n = 1u8 << (4+4); //~ WARN: arithmetic operation will overflow
7070
let n = 1i64 >> [63][0];
71-
let n = 1i64 >> [64][0]; //~ ERROR: arithmetic operation will overflow
71+
let n = 1i64 >> [64][0]; //~ WARN: arithmetic operation will overflow
7272

7373
#[cfg(target_pointer_width = "32")]
7474
const BITS: usize = 32;
7575
#[cfg(target_pointer_width = "64")]
7676
const BITS: usize = 64;
77-
let n = 1_isize << BITS; //~ ERROR: arithmetic operation will overflow
78-
let n = 1_usize << BITS; //~ ERROR: arithmetic operation will overflow
77+
let n = 1_isize << BITS; //~ WARN: arithmetic operation will overflow
78+
let n = 1_usize << BITS; //~ WARN: arithmetic operation will overflow
7979
}

0 commit comments

Comments
 (0)
Please sign in to comment.