diff options
| author | Oli Scherer <github35764891676564198441@oli-obk.de> | 2024-02-05 22:21:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-05 22:21:40 +0100 |
| commit | c94769a9748233559313c532d524f58ebb643b1d (patch) | |
| tree | 6b2eaef776497c64cdc7488b75e3b55600ef205e /compiler/rustc_const_eval | |
| parent | 5d46b982c539ef3a227bd5557ec8a1648dfc5a5c (diff) | |
| download | rust-c94769a9748233559313c532d524f58ebb643b1d.tar.gz rust-c94769a9748233559313c532d524f58ebb643b1d.zip | |
Clarify order of operations during interning
Co-authored-by: Ralf Jung <post@ralfj.de>
Diffstat (limited to 'compiler/rustc_const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intern.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index c3a53f90e60..38e7843761b 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -148,6 +148,13 @@ pub fn intern_const_alloc_recursive< // better errors. Maybe we should consider doing validation before interning in the future. while let Some(prov) = todo.pop() { let alloc_id = prov.alloc_id(); + // Crucially, we check this *before* checking whether the `alloc_id` + // has already been interned. The point of this check is to ensure that when + // there are multiple pointers to the same allocation, they are *all* immutable. + // Therefore it would be bad if we only checked the first pointer to any given + // allocation. + // (It is likely not possible to actually have multiple pointers to the same allocation, + // so alternatively we could also check that and ICE if there are multiple such pointers.) if intern_kind != InternKind::Promoted && inner_mutability == Mutability::Not && !prov.immutable() |
