Skip to content

Commit 3ad154f

Browse files
committed
Fix wrong validation clasisfication of Option<&T>::Some values
1 parent e0106d9 commit 3ad154f

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
@@ -303,7 +303,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
303303
let (lo, hi) = layout.valid_range.clone().into_inner();
304304
let max_hi = u128::max_value() >> (128 - size.bits()); // as big as the size fits
305305
assert!(hi <= max_hi);
306-
if lo == 0 && hi == max_hi {
306+
if (lo == 0 && hi == max_hi) || (hi + 1 == lo) {
307307
// Nothing to check
308308
return Ok(());
309309
}
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)