File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 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 ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0277]: the trait bound `DefaultAllocator: Allocator` is not satisfied
2+ --> $DIR/wf-packed-on-proj-of-type-as-unimpl-trait.rs:28:12
3+ |
4+ LL | struct Foo(Matrix<<DefaultAllocator as Allocator>::Buffer>);
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Allocator` is not implemented for `DefaultAllocator`
6+
7+ error: aborting due to previous error
8+
9+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments