File: wf-packed-on-proj-of-type-as-unimpl-trait.rs

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,245,360 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (31 lines) | stat: -rw-r--r-- 1,226 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// rust-lang/rust#58158: We have special-case code to deal with case
// when a type is both packed and needs drop glue, (we move the fields
// out of their potentially unaligned locations before dropping them,
// which requires they be Sized; see PR #44884).
//
// So, we need to check if a given type needs drop-glue. That requires
// that we actually know that the concrete type, and we guard against
// the type having unknown parts (i.e. type variables) by ICE'ing in
// that scenario.
//
// But in a case where we have a projection (`Type as Trait::Assoc`)
// where `Type` does not actually implement `Trait`, we of course
// cannot have a concrete type, because there is no impl to look up
// the concrete type for the associated type `Assoc`.
//
// So, this test is just making sure that in such a case that we do
// not immediately ICE, and instead allow the underlying type error to
// surface.

pub struct Matrix<S>(S);
pub struct DefaultAllocator;

pub trait Allocator { type Buffer; }

// impl Allocator for DefaultAllocator { type Buffer = (); }

#[repr(packed)]
struct Foo(Matrix<<DefaultAllocator as Allocator>::Buffer>);
//~^ ERROR the trait bound `DefaultAllocator: Allocator` is not satisfied

fn main() { }