Skip to content

Commit b1162ed

Browse files
committed
Auto merge of rust-lang#71441 - RalfJung:beta-const-validation-fix, r=Mark-Simulacrum
[beta] fix failing const validation This is the **beta branch fix** for rust-lang#71353, by reverting rust-lang#70566. r? @oli-obk Not sure if there is any extra process for the beta part. This is not a backport; we intend to "properly" fix this on master but for beta a revert is faster and less risky.
2 parents a7d891e + 622c84a commit b1162ed

6 files changed

+118
-138
lines changed

src/librustc_mir/transform/const_prop.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
604604
return None;
605605
}
606606

607+
// FIXME we need to revisit this for #67176
608+
if rvalue.needs_subst() {
609+
return None;
610+
}
611+
607612
// Perform any special handling for specific Rvalue types.
608613
// Generally, checks here fall into one of two categories:
609614
// 1. Additional checking to provide useful lints to the user
@@ -644,11 +649,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
644649
_ => {}
645650
}
646651

647-
// FIXME we need to revisit this for #67176
648-
if rvalue.needs_subst() {
649-
return None;
650-
}
651-
652652
self.use_ecx(|this| {
653653
trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place);
654654
this.ecx.eval_rvalue_into_place(rvalue, place)?;

src/test/ui/consts/const-eval/ice-generic-assoc-const.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// check-pass
1+
// build-pass (tests post-monomorphisation failure)
2+
#![crate_type = "lib"]
23

34
pub trait Nullable {
45
const NULL: Self;
@@ -13,6 +14,3 @@ impl<T> Nullable for *const T {
1314
*self == Self::NULL
1415
}
1516
}
16-
17-
fn main() {
18-
}
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,146 @@
1-
warning: this arithmetic operation will overflow
2-
--> $DIR/lint-exceeding-bitshifts.rs:18:20
1+
error: this arithmetic operation will overflow
2+
--> $DIR/lint-exceeding-bitshifts.rs:22:13
33
|
4-
LL | const N: i32 = T::N << 42;
5-
| ^^^^^^^^^^ attempt to shift left with overflow
4+
LL | let _ = x << 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 | #![warn(arithmetic_overflow, const_err)]
10+
LL | #![deny(arithmetic_overflow, const_err)]
1111
| ^^^^^^^^^^^^^^^^^^^
1212

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
13+
error: this arithmetic operation will overflow
2014
--> $DIR/lint-exceeding-bitshifts.rs:27:15
2115
|
2216
LL | let n = 1u8 << 8;
2317
| ^^^^^^^^ attempt to shift left with overflow
2418

25-
warning: this arithmetic operation will overflow
19+
error: this arithmetic operation will overflow
2620
--> $DIR/lint-exceeding-bitshifts.rs:29:15
2721
|
2822
LL | let n = 1u16 << 16;
2923
| ^^^^^^^^^^ attempt to shift left with overflow
3024

31-
warning: this arithmetic operation will overflow
25+
error: this arithmetic operation will overflow
3226
--> $DIR/lint-exceeding-bitshifts.rs:31:15
3327
|
3428
LL | let n = 1u32 << 32;
3529
| ^^^^^^^^^^ attempt to shift left with overflow
3630

37-
warning: this arithmetic operation will overflow
31+
error: this arithmetic operation will overflow
3832
--> $DIR/lint-exceeding-bitshifts.rs:33:15
3933
|
4034
LL | let n = 1u64 << 64;
4135
| ^^^^^^^^^^ attempt to shift left with overflow
4236

43-
warning: this arithmetic operation will overflow
37+
error: this arithmetic operation will overflow
4438
--> $DIR/lint-exceeding-bitshifts.rs:35:15
4539
|
4640
LL | let n = 1i8 << 8;
4741
| ^^^^^^^^ attempt to shift left with overflow
4842

49-
warning: this arithmetic operation will overflow
43+
error: this arithmetic operation will overflow
5044
--> $DIR/lint-exceeding-bitshifts.rs:37:15
5145
|
5246
LL | let n = 1i16 << 16;
5347
| ^^^^^^^^^^ attempt to shift left with overflow
5448

55-
warning: this arithmetic operation will overflow
49+
error: this arithmetic operation will overflow
5650
--> $DIR/lint-exceeding-bitshifts.rs:39:15
5751
|
5852
LL | let n = 1i32 << 32;
5953
| ^^^^^^^^^^ attempt to shift left with overflow
6054

61-
warning: this arithmetic operation will overflow
55+
error: this arithmetic operation will overflow
6256
--> $DIR/lint-exceeding-bitshifts.rs:41:15
6357
|
6458
LL | let n = 1i64 << 64;
6559
| ^^^^^^^^^^ attempt to shift left with overflow
6660

67-
warning: this arithmetic operation will overflow
61+
error: this arithmetic operation will overflow
6862
--> $DIR/lint-exceeding-bitshifts.rs:44:15
6963
|
7064
LL | let n = 1u8 >> 8;
7165
| ^^^^^^^^ attempt to shift right with overflow
7266

73-
warning: this arithmetic operation will overflow
67+
error: this arithmetic operation will overflow
7468
--> $DIR/lint-exceeding-bitshifts.rs:46:15
7569
|
7670
LL | let n = 1u16 >> 16;
7771
| ^^^^^^^^^^ attempt to shift right with overflow
7872

79-
warning: this arithmetic operation will overflow
73+
error: this arithmetic operation will overflow
8074
--> $DIR/lint-exceeding-bitshifts.rs:48:15
8175
|
8276
LL | let n = 1u32 >> 32;
8377
| ^^^^^^^^^^ attempt to shift right with overflow
8478

85-
warning: this arithmetic operation will overflow
79+
error: this arithmetic operation will overflow
8680
--> $DIR/lint-exceeding-bitshifts.rs:50:15
8781
|
8882
LL | let n = 1u64 >> 64;
8983
| ^^^^^^^^^^ attempt to shift right with overflow
9084

91-
warning: this arithmetic operation will overflow
85+
error: this arithmetic operation will overflow
9286
--> $DIR/lint-exceeding-bitshifts.rs:52:15
9387
|
9488
LL | let n = 1i8 >> 8;
9589
| ^^^^^^^^ attempt to shift right with overflow
9690

97-
warning: this arithmetic operation will overflow
91+
error: this arithmetic operation will overflow
9892
--> $DIR/lint-exceeding-bitshifts.rs:54:15
9993
|
10094
LL | let n = 1i16 >> 16;
10195
| ^^^^^^^^^^ attempt to shift right with overflow
10296

103-
warning: this arithmetic operation will overflow
97+
error: this arithmetic operation will overflow
10498
--> $DIR/lint-exceeding-bitshifts.rs:56:15
10599
|
106100
LL | let n = 1i32 >> 32;
107101
| ^^^^^^^^^^ attempt to shift right with overflow
108102

109-
warning: this arithmetic operation will overflow
103+
error: this arithmetic operation will overflow
110104
--> $DIR/lint-exceeding-bitshifts.rs:58:15
111105
|
112106
LL | let n = 1i64 >> 64;
113107
| ^^^^^^^^^^ attempt to shift right with overflow
114108

115-
warning: this arithmetic operation will overflow
109+
error: this arithmetic operation will overflow
116110
--> $DIR/lint-exceeding-bitshifts.rs:62:15
117111
|
118112
LL | let n = n << 8;
119113
| ^^^^^^ attempt to shift left with overflow
120114

121-
warning: this arithmetic operation will overflow
115+
error: this arithmetic operation will overflow
122116
--> $DIR/lint-exceeding-bitshifts.rs:64:15
123117
|
124118
LL | let n = 1u8 << -8;
125119
| ^^^^^^^^^ attempt to shift left with overflow
126120

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

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

139-
warning: this arithmetic operation will overflow
133+
error: this arithmetic operation will overflow
140134
--> $DIR/lint-exceeding-bitshifts.rs:77:15
141135
|
142136
LL | let n = 1_isize << BITS;
143137
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
144138

145-
warning: this arithmetic operation will overflow
139+
error: this arithmetic operation will overflow
146140
--> $DIR/lint-exceeding-bitshifts.rs:78:15
147141
|
148142
LL | let n = 1_usize << BITS;
149143
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
150144

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

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

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
13+
error: this arithmetic operation will overflow
2014
--> $DIR/lint-exceeding-bitshifts.rs:27:15
2115
|
2216
LL | let n = 1u8 << 8;
2317
| ^^^^^^^^ attempt to shift left with overflow
2418

25-
warning: this arithmetic operation will overflow
19+
error: this arithmetic operation will overflow
2620
--> $DIR/lint-exceeding-bitshifts.rs:29:15
2721
|
2822
LL | let n = 1u16 << 16;
2923
| ^^^^^^^^^^ attempt to shift left with overflow
3024

31-
warning: this arithmetic operation will overflow
25+
error: this arithmetic operation will overflow
3226
--> $DIR/lint-exceeding-bitshifts.rs:31:15
3327
|
3428
LL | let n = 1u32 << 32;
3529
| ^^^^^^^^^^ attempt to shift left with overflow
3630

37-
warning: this arithmetic operation will overflow
31+
error: this arithmetic operation will overflow
3832
--> $DIR/lint-exceeding-bitshifts.rs:33:15
3933
|
4034
LL | let n = 1u64 << 64;
4135
| ^^^^^^^^^^ attempt to shift left with overflow
4236

43-
warning: this arithmetic operation will overflow
37+
error: this arithmetic operation will overflow
4438
--> $DIR/lint-exceeding-bitshifts.rs:35:15
4539
|
4640
LL | let n = 1i8 << 8;
4741
| ^^^^^^^^ attempt to shift left with overflow
4842

49-
warning: this arithmetic operation will overflow
43+
error: this arithmetic operation will overflow
5044
--> $DIR/lint-exceeding-bitshifts.rs:37:15
5145
|
5246
LL | let n = 1i16 << 16;
5347
| ^^^^^^^^^^ attempt to shift left with overflow
5448

55-
warning: this arithmetic operation will overflow
49+
error: this arithmetic operation will overflow
5650
--> $DIR/lint-exceeding-bitshifts.rs:39:15
5751
|
5852
LL | let n = 1i32 << 32;
5953
| ^^^^^^^^^^ attempt to shift left with overflow
6054

61-
warning: this arithmetic operation will overflow
55+
error: this arithmetic operation will overflow
6256
--> $DIR/lint-exceeding-bitshifts.rs:41:15
6357
|
6458
LL | let n = 1i64 << 64;
6559
| ^^^^^^^^^^ attempt to shift left with overflow
6660

67-
warning: this arithmetic operation will overflow
61+
error: this arithmetic operation will overflow
6862
--> $DIR/lint-exceeding-bitshifts.rs:44:15
6963
|
7064
LL | let n = 1u8 >> 8;
7165
| ^^^^^^^^ attempt to shift right with overflow
7266

73-
warning: this arithmetic operation will overflow
67+
error: this arithmetic operation will overflow
7468
--> $DIR/lint-exceeding-bitshifts.rs:46:15
7569
|
7670
LL | let n = 1u16 >> 16;
7771
| ^^^^^^^^^^ attempt to shift right with overflow
7872

79-
warning: this arithmetic operation will overflow
73+
error: this arithmetic operation will overflow
8074
--> $DIR/lint-exceeding-bitshifts.rs:48:15
8175
|
8276
LL | let n = 1u32 >> 32;
8377
| ^^^^^^^^^^ attempt to shift right with overflow
8478

85-
warning: this arithmetic operation will overflow
79+
error: this arithmetic operation will overflow
8680
--> $DIR/lint-exceeding-bitshifts.rs:50:15
8781
|
8882
LL | let n = 1u64 >> 64;
8983
| ^^^^^^^^^^ attempt to shift right with overflow
9084

91-
warning: this arithmetic operation will overflow
85+
error: this arithmetic operation will overflow
9286
--> $DIR/lint-exceeding-bitshifts.rs:52:15
9387
|
9488
LL | let n = 1i8 >> 8;
9589
| ^^^^^^^^ attempt to shift right with overflow
9690

97-
warning: this arithmetic operation will overflow
91+
error: this arithmetic operation will overflow
9892
--> $DIR/lint-exceeding-bitshifts.rs:54:15
9993
|
10094
LL | let n = 1i16 >> 16;
10195
| ^^^^^^^^^^ attempt to shift right with overflow
10296

103-
warning: this arithmetic operation will overflow
97+
error: this arithmetic operation will overflow
10498
--> $DIR/lint-exceeding-bitshifts.rs:56:15
10599
|
106100
LL | let n = 1i32 >> 32;
107101
| ^^^^^^^^^^ attempt to shift right with overflow
108102

109-
warning: this arithmetic operation will overflow
103+
error: this arithmetic operation will overflow
110104
--> $DIR/lint-exceeding-bitshifts.rs:58:15
111105
|
112106
LL | let n = 1i64 >> 64;
113107
| ^^^^^^^^^^ attempt to shift right with overflow
114108

115-
warning: this arithmetic operation will overflow
109+
error: this arithmetic operation will overflow
116110
--> $DIR/lint-exceeding-bitshifts.rs:62:15
117111
|
118112
LL | let n = n << 8;
119113
| ^^^^^^ attempt to shift left with overflow
120114

121-
warning: this arithmetic operation will overflow
115+
error: this arithmetic operation will overflow
122116
--> $DIR/lint-exceeding-bitshifts.rs:64:15
123117
|
124118
LL | let n = 1u8 << -8;
125119
| ^^^^^^^^^ attempt to shift left with overflow
126120

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

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

139-
warning: this arithmetic operation will overflow
133+
error: this arithmetic operation will overflow
140134
--> $DIR/lint-exceeding-bitshifts.rs:77:15
141135
|
142136
LL | let n = 1_isize << BITS;
143137
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
144138

145-
warning: this arithmetic operation will overflow
139+
error: this arithmetic operation will overflow
146140
--> $DIR/lint-exceeding-bitshifts.rs:78:15
147141
|
148142
LL | let n = 1_usize << BITS;
149143
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
150144

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

0 commit comments

Comments
 (0)