Skip to content

Commit

Permalink
Rollup merge of rust-lang#71533 - pnkfelix:revert-70566-for-const-val…
Browse files Browse the repository at this point in the history
…idation-fix, r=Dylan-DPC

Revert PR 70566 for const validation fix

This is a port of PR rust-lang#71441 but ported to the master branch, as discussed in [yesterday's T-compiler meeting](https://zulip-archive.rust-lang.org/131828tcompiler/88751weeklymeeting2020042354818.html#195065903)
  • Loading branch information
Dylan-DPC committed Apr 25, 2020
2 parents 62b3624 + 7d23c3b commit 4b5b6cb
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 138 deletions.
10 changes: 5 additions & 5 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
return None;
}

// FIXME we need to revisit this for #67176
if rvalue.needs_subst() {
return None;
}

// Perform any special handling for specific Rvalue types.
// Generally, checks here fall into one of two categories:
// 1. Additional checking to provide useful lints to the user
Expand Down Expand Up @@ -636,11 +641,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
_ => {}
}

// FIXME we need to revisit this for #67176
if rvalue.needs_subst() {
return None;
}

self.use_ecx(|this| {
trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place);
this.ecx.eval_rvalue_into_place(rvalue, place)?;
Expand Down
6 changes: 2 additions & 4 deletions src/test/ui/consts/const-eval/ice-generic-assoc-const.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-pass
// build-pass (tests post-monomorphisation failure)
#![crate_type = "lib"]

pub trait Nullable {
const NULL: Self;
Expand All @@ -13,6 +14,3 @@ impl<T> Nullable for *const T {
*self == Self::NULL
}
}

fn main() {
}
62 changes: 28 additions & 34 deletions src/test/ui/lint/lint-exceeding-bitshifts.noopt.stderr
Original file line number Diff line number Diff line change
@@ -1,152 +1,146 @@
warning: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:18:20
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
LL | const N: i32 = T::N << 42;
| ^^^^^^^^^^ attempt to shift left with overflow
LL | let _ = x << 42;
| ^^^^^^^ attempt to shift left with overflow
|
note: the lint level is defined here
--> $DIR/lint-exceeding-bitshifts.rs:9:9
|
LL | #![warn(arithmetic_overflow, const_err)]
LL | #![deny(arithmetic_overflow, const_err)]
| ^^^^^^^^^^^^^^^^^^^

warning: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
LL | let _ = x << 42;
| ^^^^^^^ attempt to shift left with overflow

warning: this arithmetic operation will overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:27:15
|
LL | let n = 1u8 << 8;
| ^^^^^^^^ attempt to shift left with overflow

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

warning: 24 warnings emitted
error: aborting due to 23 previous errors

62 changes: 28 additions & 34 deletions src/test/ui/lint/lint-exceeding-bitshifts.opt.stderr
Original file line number Diff line number Diff line change
@@ -1,152 +1,146 @@
warning: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:18:20
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
LL | const N: i32 = T::N << 42;
| ^^^^^^^^^^ attempt to shift left with overflow
LL | let _ = x << 42;
| ^^^^^^^ attempt to shift left with overflow
|
note: the lint level is defined here
--> $DIR/lint-exceeding-bitshifts.rs:9:9
|
LL | #![warn(arithmetic_overflow, const_err)]
LL | #![deny(arithmetic_overflow, const_err)]
| ^^^^^^^^^^^^^^^^^^^

warning: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
LL | let _ = x << 42;
| ^^^^^^^ attempt to shift left with overflow

warning: this arithmetic operation will overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:27:15
|
LL | let n = 1u8 << 8;
| ^^^^^^^^ attempt to shift left with overflow

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

warning: 24 warnings emitted
error: aborting due to 23 previous errors

Loading

0 comments on commit 4b5b6cb

Please sign in to comment.