about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-08-16 00:45:02 +0000
committerMichael Goulet <michael@errs.io>2023-08-16 01:57:33 +0000
commitc31aedf47f946e616169d4e0b95f898981b4e84b (patch)
treec7f811c4ba294c3722a0ece7987fdb6a47bae3ee
parentc57393e4f8b88444fbf0985a81a2d662862f2733 (diff)
downloadrust-c31aedf47f946e616169d4e0b95f898981b4e84b.tar.gz
rust-c31aedf47f946e616169d4e0b95f898981b4e84b.zip
Don't ICE in is_trivially_sized when encountering late-bound self ty
-rw-r--r--compiler/rustc_middle/src/ty/sty.rs4
-rw-r--r--tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.rs19
-rw-r--r--tests/ui/traits/non_lifetime_binders/sized-late-bound-issue-114872.stderr11
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
+