From 3009cb3f6bded69d83b1d5fe22b26612496e87fc Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 12 May 2023 00:58:02 +0000 Subject: Don't ICE in layout computation for placeholder types --- compiler/rustc_middle/src/ty/sty.rs | 6 ++---- .../check-size-at-cast-polymorphic-bad.current.stderr | 15 +++++++++++++++ .../check-size-at-cast-polymorphic-bad.next.stderr | 15 +++++++++++++++ tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs | 3 +++ .../ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr | 15 --------------- 5 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr create mode 100644 tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr delete mode 100644 tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr 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.current.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr new file mode 100644 index 00000000000..ba42f619a54 --- /dev/null +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.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: &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.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: &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)] 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.stderr deleted file mode 100644 index 8726fae79a0..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: `&T` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast-polymorphic-bad.rs:11: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: &T) where &T: PointerLike { - | +++++++++++++++++++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. -- cgit 1.4.1-3-g733a5