Skip to content

Commit 76be8b7

Browse files
authored
Unrolled build for rust-lang#129179
Rollup merge of rust-lang#129179 - compiler-errors:cfi-erase-transparent, r=davidtwco CFI: Erase regions when projecting ADT to its transparent non-1zst field The output from `FieldDef::ty` (or `TyCtxt::type_of`) may have free regions (well, `'static`) -- erase it. Fixes rust-lang#129169 Fixes rust-lang#123685
2 parents 982c6f8 + c8ae02f commit 76be8b7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for TransformTy<'tcx> {
146146
!is_zst
147147
});
148148
if let Some(field) = field {
149-
let ty0 = self.tcx.type_of(field.did).instantiate(self.tcx, args);
149+
let ty0 = self.tcx.erase_regions(field.ty(self.tcx, args));
150150
// Generalize any repr(transparent) user-defined type that is either a
151151
// pointer or reference, and either references itself or any other type that
152152
// contains or references itself, to avoid a reference cycle.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ needs-sanitizer-cfi
2+
//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
3+
//@ no-prefer-dynamic
4+
//@ only-x86_64-unknown-linux-gnu
5+
//@ build-pass
6+
7+
pub trait Trait {}
8+
9+
impl Trait for i32 {}
10+
11+
#[repr(transparent)]
12+
struct BoxedTrait(Box<dyn Trait + 'static>);
13+
14+
fn hello(x: BoxedTrait) {}
15+
16+
fn main() {
17+
hello(BoxedTrait(Box::new(1)));
18+
}

0 commit comments

Comments
 (0)