Skip to content

Commit 78b680e

Browse files
committed
interpret: mark a dead match arm as dead
1 parent 1fca19c commit 78b680e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
444444
match scalar.try_to_int() {
445445
Ok(int) => int.is_null(),
446446
Err(_) => {
447+
// Can only happen during CTFE.
447448
let ptr = self.scalar_to_ptr(scalar);
448449
match self.memory.ptr_try_get_alloc(ptr) {
449450
Ok((alloc_id, offset, _)) => {
@@ -455,7 +456,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
455456
// Note that one-past-the-end (offset == size) is still inbounds, and never null.
456457
offset > size
457458
}
458-
Err(offset) => offset == 0,
459+
Err(_offset) => bug!("a non-int scalar is always a pointer"),
459460
}
460461
}
461462
}

0 commit comments

Comments
 (0)