diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-12 07:11:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-12 07:11:14 +0200 |
| commit | 4c12f5d25202bbf957d5807dfef26daa70f2f593 (patch) | |
| tree | a2edecf899392158d122947e4d1975ace3594cf0 | |
| parent | 1d4689cb99f21c0f04c544b52073133cd50f2ad5 (diff) | |
| parent | 3009cb3f6bded69d83b1d5fe22b26612496e87fc (diff) | |
| download | rust-4c12f5d25202bbf957d5807dfef26daa70f2f593.tar.gz rust-4c12f5d25202bbf957d5807dfef26daa70f2f593.zip | |
Rollup merge of #111490 - compiler-errors:layout-placeholder, r=aliemjay
Don't ICE in layout computation for placeholder types We use `layout_of` for the built-in `PointerLike` trait to check if a type can be coerced to a `dyn*`. Since the new solver canonicalizes parameter types to placeholders, that code needs to be able to treat placeholders like params, and for the most part it does, **except** for a call to `is_trivially_sized`. This PR fixes that.
| -rw-r--r-- | compiler/rustc_middle/src/ty/sty.rs | 6 | ||||
| -rw-r--r-- | tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr (renamed from tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr) | 2 | ||||
| -rw-r--r-- | tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr | 15 | ||||
| -rw-r--r-- | tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs | 3 |
4 files changed, 21 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 8d0737e1eee..488d83b5f67 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -2366,13 +2366,11 @@ impl<'tcx> Ty<'tcx> { ty::Adt(def, _substs) => def.sized_constraint(tcx).0.is_empty(), - ty::Alias(..) | ty::Param(_) => false, + ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => false, ty::Infer(ty::TyVar(_)) => false, - ty::Bound(..) - | ty::Placeholder(..) - | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { + ty::Bound(..) | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!("`is_trivially_sized` applied to unexpected type: {:?}", self) } } diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr index 8726fae79a0..ba42f619a54 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr @@ -1,5 +1,5 @@ error[E0277]: `&T` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast-polymorphic-bad.rs:11:15 + --> $DIR/check-size-at-cast-polymorphic-bad.rs:14:15 | LL | dyn_debug(t); | ^ `&T` needs to be a pointer-like type diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr new file mode 100644 index 00000000000..ba42f619a54 --- /dev/null +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr @@ -0,0 +1,15 @@ +error[E0277]: `&T` needs to have the same ABI as a pointer + --> $DIR/check-size-at-cast-polymorphic-bad.rs:14:15 + | +LL | dyn_debug(t); + | ^ `&T` needs to be a pointer-like type + | + = help: the trait `PointerLike` is not implemented for `&T` +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn polymorphic<T: Debug + ?Sized>(t: &T) where &T: PointerLike { + | +++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs index 913c2faacbd..9846f871424 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + #![feature(dyn_star)] #![allow(incomplete_features)] |
