Skip to content

Commit 3009cb3

Browse files
Don't ICE in layout computation for placeholder types
1 parent 2a8221d commit 3009cb3

4 files changed

+21
-5
lines changed

compiler/rustc_middle/src/ty/sty.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2366,13 +2366,11 @@ impl<'tcx> Ty<'tcx> {
23662366

23672367
ty::Adt(def, _substs) => def.sized_constraint(tcx).0.is_empty(),
23682368

2369-
ty::Alias(..) | ty::Param(_) => false,
2369+
ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => false,
23702370

23712371
ty::Infer(ty::TyVar(_)) => false,
23722372

2373-
ty::Bound(..)
2374-
| ty::Placeholder(..)
2375-
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2373+
ty::Bound(..) | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
23762374
bug!("`is_trivially_sized` applied to unexpected type: {:?}", self)
23772375
}
23782376
}

tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: `&T` needs to have the same ABI as a pointer
2-
--> $DIR/check-size-at-cast-polymorphic-bad.rs:11:15
2+
--> $DIR/check-size-at-cast-polymorphic-bad.rs:14:15
33
|
44
LL | dyn_debug(t);
55
| ^ `&T` needs to be a pointer-like type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0277]: `&T` needs to have the same ABI as a pointer
2+
--> $DIR/check-size-at-cast-polymorphic-bad.rs:14:15
3+
|
4+
LL | dyn_debug(t);
5+
| ^ `&T` needs to be a pointer-like type
6+
|
7+
= help: the trait `PointerLike` is not implemented for `&T`
8+
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
9+
|
10+
LL | fn polymorphic<T: Debug + ?Sized>(t: &T) where &T: PointerLike {
11+
| +++++++++++++++++++++
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0277`.

tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// revisions: current next
2+
//[next] compile-flags: -Ztrait-solver=next
3+
14
#![feature(dyn_star)]
25
#![allow(incomplete_features)]
36

0 commit comments

Comments
 (0)