Skip to content

Commit

Permalink
Don't ICE in layout computation for placeholder types
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed May 12, 2023
1 parent 2a8221d commit 3009cb3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 2 additions & 4 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr
Original file line number Diff line number Diff line change
@@ -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`.
3 changes: 3 additions & 0 deletions tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next

#![feature(dyn_star)]
#![allow(incomplete_features)]

Expand Down

0 comments on commit 3009cb3

Please sign in to comment.