const-eval interning: accpt interior mutable pointers in final value (but keep rejecting mutable references)

This commit is contained in:
Ralf Jung 2024-08-02 15:34:59 +02:00
parent 304b7f801b
commit f76f128dc9
21 changed files with 177 additions and 563 deletions

View file

@ -538,8 +538,9 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
// final value.
// Note: This is only sound if every local that has a `StorageDead` has a
// `StorageDead` in every control flow path leading to a `return` terminator.
// The good news is that interning will detect if any unexpected mutable
// pointer slips through.
// If anything slips through, there's no safety net -- safe code can create
// references to variants of `!Freeze` enums as long as that variant is `Freeze`,
// so interning can't protect us here.
if self.local_is_transient(place.local) {
self.check_op(ops::TransientCellBorrow);
} else {