diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2019-03-08 09:42:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-08 09:42:12 +0100 |
| commit | c51c90c8917caf0192ce8d76da72ada03891818b (patch) | |
| tree | 28c0d01c8bc2b2bfe798e314561fb340a0c60221 /src/test | |
| parent | 378a0118f36f99425773bbd3b6dd9db571616f5c (diff) | |
| parent | 533f011d46c7759b04976339ab98cfb3cf7bb058 (diff) | |
| download | rust-c51c90c8917caf0192ce8d76da72ada03891818b.tar.gz rust-c51c90c8917caf0192ce8d76da72ada03891818b.zip | |
Rollup merge of #58970 - pnkfelix:issue-58158-size-of-assoc-type-ice, r=petrochenkov
delay_span_bug in wfcheck's ty.lift_to_tcx unwrap Fix #58158
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/wf/wf-packed-on-proj-of-type-as-unimpl-trait.rs | 31 | ||||
| -rw-r--r-- | src/test/ui/wf/wf-packed-on-proj-of-type-as-unimpl-trait.stderr | 9 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/test/ui/wf/wf-packed-on-proj-of-type-as-unimpl-trait.rs b/src/test/ui/wf/wf-packed-on-proj-of-type-as-unimpl-trait.rs new file mode 100644 index 00000000000..d0167c8c268 --- /dev/null +++ b/src/test/ui/wf/wf-packed-on-proj-of-type-as-unimpl-trait.rs @@ -0,0 +1,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() { } diff --git a/src/test/ui/wf/wf-packed-on-proj-of-type-as-unimpl-trait.stderr b/src/test/ui/wf/wf-packed-on-proj-of-type-as-unimpl-trait.stderr new file mode 100644 index 00000000000..e460cdcd3f3 --- /dev/null +++ b/src/test/ui/wf/wf-packed-on-proj-of-type-as-unimpl-trait.stderr @@ -0,0 +1,9 @@ +error[E0277]: the trait bound `DefaultAllocator: Allocator` is not satisfied + --> $DIR/wf-packed-on-proj-of-type-as-unimpl-trait.rs:28:12 + | +LL | struct Foo(Matrix<<DefaultAllocator as Allocator>::Buffer>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Allocator` is not implemented for `DefaultAllocator` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
