Skip to content

Commit 04da282

Browse files
committed
Auto merge of #55581 - oli-obk:beta, r=pietroalbini
[beta] Fix wrong validation clasisfication of `Option<&T>::Some` values r? @pietroalbini original PR: #55474
2 parents 52055d1 + b4b0744 commit 04da282

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/librustc_mir/interpret/validity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
289289
let (lo, hi) = layout.valid_range.clone().into_inner();
290290
let max_hi = u128::max_value() >> (128 - size.bits()); // as big as the size fits
291291
assert!(hi <= max_hi);
292-
if lo == 0 && hi == max_hi {
292+
if (lo == 0 && hi == max_hi) || (hi + 1 == lo) {
293293
// Nothing to check
294294
return Ok(());
295295
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// https://github.com/rust-lang/rust/issues/55454
2+
// compile-pass
3+
4+
struct This<T>(T);
5+
6+
const C: This<Option<&i32>> = This(Some(&1));
7+
8+
fn main() {
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// https://github.com/rust-lang/rust/issues/55454
2+
// compile-pass
3+
4+
#[derive(PartialEq)]
5+
struct This<T>(T);
6+
7+
fn main() {
8+
This(Some(&1)) == This(Some(&1));
9+
}

0 commit comments

Comments
 (0)