diff options
| author | Michael Goulet <michael@errs.io> | 2023-08-16 00:45:02 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-08-16 01:57:33 +0000 |
| commit | c31aedf47f946e616169d4e0b95f898981b4e84b (patch) | |
| tree | c7f811c4ba294c3722a0ece7987fdb6a47bae3ee | |
| parent | c57393e4f8b88444fbf0985a81a2d662862f2733 (diff) | |
| download | rust-c31aedf47f946e616169d4e0b95f898981b4e84b.tar.gz rust-c31aedf47f946e616169d4e0b95f898981b4e84b.zip | |
Don't ICE in is_trivially_sized when encountering late-bound self ty
3 files changed, 32 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index e6baa624205..0291cdd6c57 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -2827,11 +2827,11 @@ impl<'tcx> Ty<'tcx> { 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::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) } } diff --git a/tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.rs b/tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.rs new file mode 100644 index 00000000000..ba55ab07185 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.rs @@ -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() {} diff --git a/tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.stderr b/tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.stderr new file mode 100644 index 00000000000..e75d8127052 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.stderr @@ -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 + |
