diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-21 18:15:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-21 18:15:02 +0200 |
| commit | 7da4b2d82ad67816de1f49ff49c013b439f28f17 (patch) | |
| tree | 34b0078d25b1a8bd7f599a22c4e424535eda7c00 /tests/ui/sanitizer | |
| parent | 48c9864a0561fca29ce5c26535abd81cbe612097 (diff) | |
| parent | c8ae02fb842fcd4b2f3a75e279bd61c141552c55 (diff) | |
| download | rust-7da4b2d82ad67816de1f49ff49c013b439f28f17.tar.gz rust-7da4b2d82ad67816de1f49ff49c013b439f28f17.zip | |
Rollup merge of #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 #129169 Fixes #123685
Diffstat (limited to 'tests/ui/sanitizer')
| -rw-r--r-- | tests/ui/sanitizer/cfi/transparent-has-regions.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/sanitizer/cfi/transparent-has-regions.rs b/tests/ui/sanitizer/cfi/transparent-has-regions.rs new file mode 100644 index 00000000000..b70e1ea1791 --- /dev/null +++ b/tests/ui/sanitizer/cfi/transparent-has-regions.rs @@ -0,0 +1,18 @@ +//@ needs-sanitizer-cfi +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ no-prefer-dynamic +//@ only-x86_64-unknown-linux-gnu +//@ build-pass + +pub trait Trait {} + +impl Trait for i32 {} + +#[repr(transparent)] +struct BoxedTrait(Box<dyn Trait + 'static>); + +fn hello(x: BoxedTrait) {} + +fn main() { + hello(BoxedTrait(Box::new(1))); +} |
