File tree 4 files changed +15
-6
lines changed
rustc_codegen_llvm/src/debuginfo
rustc_const_eval/src/interpret
4 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,8 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
216
216
// need to make sure that we don't break existing debuginfo consumers
217
217
// by doing that (at least not without a warning period).
218
218
let layout_type = if ptr_type. is_box ( ) {
219
+ // The assertion at the start of this function ensures we have a ZST allocator.
220
+ // We'll make debuginfo "skip" all ZST allocators, not just the default allocator.
219
221
Ty :: new_mut_ptr ( cx. tcx , pointee_type)
220
222
} else {
221
223
ptr_type
Original file line number Diff line number Diff line change @@ -438,14 +438,16 @@ where
438
438
& self ,
439
439
src : & impl Readable < ' tcx , M :: Provenance > ,
440
440
) -> InterpResult < ' tcx , MPlaceTy < ' tcx , M :: Provenance > > {
441
+ if src. layout ( ) . ty . is_box ( ) {
442
+ // Derefer should have removed all Box derefs.
443
+ // Some `Box` are not immediates (if they have a custom allocator)
444
+ // so the code below would fail.
445
+ bug ! ( "dereferencing {}" , src. layout( ) . ty) ;
446
+ }
447
+
441
448
let val = self . read_immediate ( src) ?;
442
449
trace ! ( "deref to {} on {:?}" , val. layout. ty, * val) ;
443
450
444
- if val. layout . ty . is_box ( ) {
445
- // Derefer should have removed all Box derefs
446
- bug ! ( "dereferencing {}" , val. layout. ty) ;
447
- }
448
-
449
451
let mplace = self . ref_to_mplace ( & val) ?;
450
452
Ok ( mplace)
451
453
}
Original file line number Diff line number Diff line change @@ -1149,7 +1149,10 @@ impl<'tcx> Ty<'tcx> {
1149
1149
}
1150
1150
}
1151
1151
1152
- /// Tests whether this is a Box using the global allocator.
1152
+ /// Tests whether this is a Box definitely using the global allocator.
1153
+ ///
1154
+ /// If the allocator is still generic, the answer is `false`, but it may
1155
+ /// later turn out that it does use the global allocator.
1153
1156
#[ inline]
1154
1157
pub fn is_box_global ( self , tcx : TyCtxt < ' tcx > ) -> bool {
1155
1158
match self . kind ( ) {
Original file line number Diff line number Diff line change @@ -137,6 +137,8 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
137
137
// Using `is_box_global` here is a bit sketchy: if this code is
138
138
// generic over the allocator, we'll not add a retag! This is a hack
139
139
// to make Stacked Borrows compatible with custom allocator code.
140
+ // It means the raw pointer inherits the tag of the box, which mostly works
141
+ // but can sometimes lead to unexpected aliasing errors.
140
142
// Long-term, we'll want to move to an aliasing model where "cast to
141
143
// raw pointer" is a complete NOP, and then this will no longer be
142
144
// an issue.
You can’t perform that action at this time.
0 commit comments