]> git.proxmox.com Git - rustc.git/blob - tests/ui/wf/wf-packed-on-proj-of-type-as-unimpl-trait.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / wf / wf-packed-on-proj-of-type-as-unimpl-trait.rs
1 // rust-lang/rust#58158: We have special-case code to deal with case
2 // when a type is both packed and needs drop glue, (we move the fields
3 // out of their potentially unaligned locations before dropping them,
4 // which requires they be Sized; see PR #44884).
5 //
6 // So, we need to check if a given type needs drop-glue. That requires
7 // that we actually know that the concrete type, and we guard against
8 // the type having unknown parts (i.e. type variables) by ICE'ing in
9 // that scenario.
10 //
11 // But in a case where we have a projection (`Type as Trait::Assoc`)
12 // where `Type` does not actually implement `Trait`, we of course
13 // cannot have a concrete type, because there is no impl to look up
14 // the concrete type for the associated type `Assoc`.
15 //
16 // So, this test is just making sure that in such a case that we do
17 // not immediately ICE, and instead allow the underlying type error to
18 // surface.
19
20 pub struct Matrix<S>(S);
21 pub struct DefaultAllocator;
22
23 pub trait Allocator { type Buffer; }
24
25 // impl Allocator for DefaultAllocator { type Buffer = (); }
26
27 #[repr(packed)]
28 struct Foo(Matrix<<DefaultAllocator as Allocator>::Buffer>);
29 //~^ ERROR the trait bound `DefaultAllocator: Allocator` is not satisfied
30
31 fn main() { }