Don't ICE in is_trivially_sized when encountering late-bound self ty

This commit is contained in:
Michael Goulet 2023-08-16 00:45:02 +00:00
parent c57393e4f8
commit c31aedf47f
3 changed files with 32 additions and 2 deletions

View file

@ -2827,11 +2827,11 @@ impl<'tcx> Ty<'tcx> {
ty::Adt(def, _args) => def.sized_constraint(tcx).skip_binder().is_empty(), ty::Adt(def, _args) => def.sized_constraint(tcx).skip_binder().is_empty(),
ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => false, ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) | ty::Bound(..) => false,
ty::Infer(ty::TyVar(_)) => false, ty::Infer(ty::TyVar(_)) => false,
ty::Bound(..) | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
bug!("`is_trivially_sized` applied to unexpected type: {:?}", self) bug!("`is_trivially_sized` applied to unexpected type: {:?}", self)
} }
} }

View file

@ -0,0 +1,19 @@
// check-pass
#![feature(non_lifetime_binders)]
//~^ WARN is incomplete and may not be safe
pub fn foo()
where
for<V> V: Sized,
{
bar();
}
pub fn bar()
where
for<V> V: Sized,
{
}
pub fn main() {}

View file

@ -0,0 +1,11 @@
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/sized-late-bound-issue-114872.rs:3:12
|
LL | #![feature(non_lifetime_binders)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: 1 warning emitted