Rollup merge of #129812 - RalfJung:box-custom-alloc, r=compiler-errors

interpret, codegen: tweak some comments and checks regarding Box with custom allocator

Cc https://github.com/rust-lang/rust/issues/95453
This commit is contained in:
Matthias Krüger 2024-08-31 14:46:14 +02:00 committed by GitHub
commit 830b1deaee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 6 deletions

View file

@ -137,6 +137,8 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
// Using `is_box_global` here is a bit sketchy: if this code is
// generic over the allocator, we'll not add a retag! This is a hack
// to make Stacked Borrows compatible with custom allocator code.
// It means the raw pointer inherits the tag of the box, which mostly works
// but can sometimes lead to unexpected aliasing errors.
// Long-term, we'll want to move to an aliasing model where "cast to
// raw pointer" is a complete NOP, and then this will no longer be
// an issue.