Skip to content

Commit 69ffe7b

Browse files
committed
Address review comments
1 parent 7bd01ed commit 69ffe7b

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

src/librustc_mir/interpret/intern.rs

+3-23
Original file line numberDiff line numberDiff line change
@@ -385,29 +385,9 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
385385
} else if ecx.memory.dead_alloc_map.contains_key(&alloc_id) {
386386
// dangling pointer
387387
throw_unsup!(ValidationFailure("encountered dangling pointer in final constant".into()))
388-
} else if let Some(_) = ecx.tcx.alloc_map.lock().get(alloc_id) {
389-
// We have hit an `AllocId` that belongs to an already interned static,
390-
// and are thus not interning any further.
391-
392-
// For `InternKind::Promoted` this is only reachable for allocations
393-
// created for string and byte string literals, since these are interned immediately
394-
// at creation time.
395-
396-
// FIXME(oli-obk): Since we are also checking things during interning,
397-
// we should probably continue doing those checks no matter what we encounter.
398-
// So we basically have to check if the allocation is ok as per the interning rules as
399-
// if we interned it right here.
400-
// This should be as simple as
401-
/*
402-
for &(_, ((), reloc)) in alloc.relocations().iter() {
403-
if leftover_allocations.insert(reloc) {
404-
todo.push(reloc);
405-
}
406-
}
407-
*/
408-
// But I (oli-obk) haven't thought about the ramnificatons yet. This also would cause
409-
// compile-time regressions, so we should think about caching these.
410-
} else {
388+
} else if ecx.tcx.alloc_map.lock().get(alloc_id).is_none() {
389+
// We have hit an `AllocId` that is neither in local or global memory and isn't marked
390+
// as dangling by local memory.
411391
span_bug!(ecx.tcx.span, "encountered unknown alloc id {:?}", alloc_id);
412392
}
413393
}

0 commit comments

Comments
 (0)