Skip to content

Commit

Permalink
Auto merge of #55581 - oli-obk:beta, r=pietroalbini
Browse files Browse the repository at this point in the history
[beta] Fix wrong validation clasisfication of `Option<&T>::Some` values

r? @pietroalbini

original PR: #55474
  • Loading branch information
bors committed Nov 1, 2018
2 parents 52055d1 + b4b0744 commit 04da282
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
let (lo, hi) = layout.valid_range.clone().into_inner();
let max_hi = u128::max_value() >> (128 - size.bits()); // as big as the size fits
assert!(hi <= max_hi);
if lo == 0 && hi == max_hi {
if (lo == 0 && hi == max_hi) || (hi + 1 == lo) {
// Nothing to check
return Ok(());
}
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/consts/const-validation-fail-55455.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://github.com/rust-lang/rust/issues/55454
// compile-pass

struct This<T>(T);

const C: This<Option<&i32>> = This(Some(&1));

fn main() {
}
9 changes: 9 additions & 0 deletions src/test/ui/consts/promoted-validation-55454.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://github.com/rust-lang/rust/issues/55454
// compile-pass

#[derive(PartialEq)]
struct This<T>(T);

fn main() {
This(Some(&1)) == This(Some(&1));
}

0 comments on commit 04da282

Please sign in to comment.