Skip to content

Commit

Permalink
Rollup merge of #120587 - lukas-code:miri-tail-normalize, r=RalfJung
Browse files Browse the repository at this point in the history
miri: normalize struct tail in ABI compat check

fixes #3282
extracted from rust-lang/rust#120354, see rust-lang/rust#120354 (comment) for context

r? ```@RalfJung```
  • Loading branch information
matthiaskrgr committed Feb 5, 2024
2 parents b33c174 + 8ee8d26 commit a6302b9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/pass/issues/issue-miri-3282-struct-tail-normalize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// regression test for an ICE: https://github.com/rust-lang/miri/issues/3282

trait Id {
type Assoc: ?Sized;
}

impl<T: ?Sized> Id for T {
type Assoc = T;
}

#[repr(transparent)]
struct Foo<T: ?Sized> {
field: <T as Id>::Assoc,
}

fn main() {
let x = unsafe { std::mem::transmute::<fn(&str), fn(&Foo<str>)>(|_| ()) };
let foo: &Foo<str> = unsafe { &*("uwu" as *const str as *const Foo<str>) };
x(foo);
}

0 comments on commit a6302b9

Please sign in to comment.