about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2025-04-21 15:55:58 +0000
committerGitHub <noreply@github.com>2025-04-21 15:55:58 +0000
commitf79eef91df057d17dd8123f2e8f61232762bdbd7 (patch)
treee5c306d9e95ebb8c3f91cf911ed2b7f04eb6e79e /tests
parent24bd5649b1d7fd3c0467703f249ac05fb0991567 (diff)
parent47911eb677a29006d243a0b6bf17f26486191ead (diff)
downloadrust-f79eef91df057d17dd8123f2e8f61232762bdbd7.tar.gz
rust-f79eef91df057d17dd8123f2e8f61232762bdbd7.zip
Rollup merge of #140021 - compiler-errors:no-deep-norm-ice, r=lcnr
Don't ICE on pending obligations from deep normalization in a loop

See the comment I left inline in `compiler/rustc_trait_selection/src/traits/normalize.rs`.

Fixes https://github.com/rust-lang/rust/issues/133868

r? lcnr
Diffstat (limited to 'tests')
-rw-r--r--tests/crashes/133868.rs13
-rw-r--r--tests/ui/traits/deep-norm-pending.rs24
-rw-r--r--tests/ui/traits/deep-norm-pending.stderr130
3 files changed, 154 insertions, 13 deletions
diff --git a/tests/crashes/133868.rs b/tests/crashes/133868.rs
deleted file mode 100644
index dc25cb9df28..00000000000
--- a/tests/crashes/133868.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-//@ known-bug: #133868
-
-trait Foo {
-    type Assoc;
-}
-
-trait Bar {
-    fn method() -> impl Sized;
-}
-impl<T> Bar for T where <T as Foo>::Assoc: Sized
-{
-    fn method() {}
-}
diff --git a/tests/ui/traits/deep-norm-pending.rs b/tests/ui/traits/deep-norm-pending.rs
new file mode 100644
index 00000000000..f56c3cfa3ea
--- /dev/null
+++ b/tests/ui/traits/deep-norm-pending.rs
@@ -0,0 +1,24 @@
+trait Foo {
+    type Assoc;
+}
+
+trait Bar {
+    fn method() -> impl Sized;
+    //~^ ERROR the trait bound `T: Foo` is not satisfied
+}
+impl<T> Bar for T
+//~^ ERROR the trait bound `T: Foo` is not satisfied
+//~| ERROR the trait bound `T: Foo` is not satisfied
+where
+    <T as Foo>::Assoc: Sized,
+{
+    fn method() {}
+    //~^ ERROR the trait bound `T: Foo` is not satisfied
+    //~| ERROR the trait bound `T: Foo` is not satisfied
+    //~| ERROR the trait bound `T: Foo` is not satisfied
+    //~| ERROR the trait bound `T: Foo` is not satisfied
+    //~| ERROR the trait bound `T: Foo` is not satisfied
+    //~| ERROR the trait bound `T: Foo` is not satisfied
+}
+
+fn main() {}
diff --git a/tests/ui/traits/deep-norm-pending.stderr b/tests/ui/traits/deep-norm-pending.stderr
new file mode 100644
index 00000000000..b95b9d7f4ae
--- /dev/null
+++ b/tests/ui/traits/deep-norm-pending.stderr
@@ -0,0 +1,130 @@
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/deep-norm-pending.rs:15:5
+   |
+LL |     fn method() {}
+   |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
+   |
+help: consider further restricting type parameter `T` with trait `Foo`
+   |
+LL |     <T as Foo>::Assoc: Sized, T: Foo
+   |                               ++++++
+
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/deep-norm-pending.rs:9:1
+   |
+LL | / impl<T> Bar for T
+LL | |
+LL | |
+LL | | where
+LL | |     <T as Foo>::Assoc: Sized,
+   | |_____________________________^ the trait `Foo` is not implemented for `T`
+   |
+help: consider further restricting type parameter `T` with trait `Foo`
+   |
+LL |     <T as Foo>::Assoc: Sized, T: Foo
+   |                               ++++++
+
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/deep-norm-pending.rs:9:1
+   |
+LL | / impl<T> Bar for T
+LL | |
+LL | |
+LL | | where
+...  |
+LL | | }
+   | |_^ the trait `Foo` is not implemented for `T`
+   |
+help: consider further restricting type parameter `T` with trait `Foo`
+   |
+LL |     <T as Foo>::Assoc: Sized, T: Foo
+   |                               ++++++
+
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/deep-norm-pending.rs:15:5
+   |
+LL |     fn method() {}
+   |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+help: consider further restricting type parameter `T` with trait `Foo`
+   |
+LL |     <T as Foo>::Assoc: Sized, T: Foo
+   |                               ++++++
+
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/deep-norm-pending.rs:15:5
+   |
+LL |     fn method() {}
+   |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
+   |
+note: required for `T` to implement `Bar`
+  --> $DIR/deep-norm-pending.rs:9:9
+   |
+LL | impl<T> Bar for T
+   |         ^^^     ^
+...
+LL |     <T as Foo>::Assoc: Sized,
+   |                        ----- unsatisfied trait bound introduced here
+help: consider further restricting type parameter `T` with trait `Foo`
+   |
+LL |     <T as Foo>::Assoc: Sized, T: Foo
+   |                               ++++++
+
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/deep-norm-pending.rs:15:5
+   |
+LL |     fn method() {}
+   |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+help: consider further restricting type parameter `T` with trait `Foo`
+   |
+LL |     <T as Foo>::Assoc: Sized, T: Foo
+   |                               ++++++
+
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/deep-norm-pending.rs:6:20
+   |
+LL |     fn method() -> impl Sized;
+   |                    ^^^^^^^^^^ the trait `Foo` is not implemented for `T`
+   |
+note: required for `T` to implement `Bar`
+  --> $DIR/deep-norm-pending.rs:9:9
+   |
+LL | impl<T> Bar for T
+   |         ^^^     ^
+...
+LL |     <T as Foo>::Assoc: Sized,
+   |                        ----- unsatisfied trait bound introduced here
+help: consider further restricting type parameter `T` with trait `Foo`
+   |
+LL |     <T as Foo>::Assoc: Sized, T: Foo
+   |                               ++++++
+
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/deep-norm-pending.rs:15:5
+   |
+LL |     fn method() {}
+   |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+help: consider further restricting type parameter `T` with trait `Foo`
+   |
+LL |     <T as Foo>::Assoc: Sized, T: Foo
+   |                               ++++++
+
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/deep-norm-pending.rs:15:8
+   |
+LL |     fn method() {}
+   |        ^^^^^^ the trait `Foo` is not implemented for `T`
+   |
+help: consider further restricting type parameter `T` with trait `Foo`
+   |
+LL |     <T as Foo>::Assoc: Sized, T: Foo
+   |                               ++++++
+
+error: aborting due to 9 previous errors
+
+For more information about this error, try `rustc --explain E0277`.