diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-11-23 20:32:35 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-23 20:32:35 +0530 |
| commit | bd91c94a5d744e0f93aff073bdbb69d0f4e8d9f6 (patch) | |
| tree | 7796e86984ee33de8899878a240592e49a22fe15 /src | |
| parent | 4e0d0d757e2f1b61ec809420b006545a9f8974c0 (diff) | |
| parent | 9decfff6f87d3e5760fd61375c3d27fa45a83e52 (diff) | |
| download | rust-bd91c94a5d744e0f93aff073bdbb69d0f4e8d9f6.tar.gz rust-bd91c94a5d744e0f93aff073bdbb69d0f4e8d9f6.zip | |
Rollup merge of #104269 - compiler-errors:hang-in-where-clause-sugg, r=lcnr
Fix hang in where-clause suggestion with `predicate_can_apply` Using `predicate_may_hold` during error reporting causes an evaluation overflow, which (because we use `evaluate_obligation_no_overflow`) then causes the predicate to need to be re-evaluated locally, which results in a hang. ... but since the "add a where clause" suggestion is best-effort, just throw any overflow errors. No need for 100% accuracy. r? `@lcnr` who has been thinking about overflows... Let me know if you want more context about this issue, and as always, feel free to reassign. Fixes #104225
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/traits/predicate_can_apply-hang.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/traits/predicate_can_apply-hang.stderr | 21 | ||||
| -rw-r--r-- | src/test/ui/typeck/hang-in-overflow.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/typeck/hang-in-overflow.stderr | 22 |
4 files changed, 68 insertions, 0 deletions
diff --git a/src/test/ui/traits/predicate_can_apply-hang.rs b/src/test/ui/traits/predicate_can_apply-hang.rs new file mode 100644 index 00000000000..5f01645da52 --- /dev/null +++ b/src/test/ui/traits/predicate_can_apply-hang.rs @@ -0,0 +1,6 @@ +fn f<B>(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq<B> { + //~^ ERROR can't compare `Vec<[[[B; 1]; 1]; 1]>` with `B` + x +} + +fn main() {} diff --git a/src/test/ui/traits/predicate_can_apply-hang.stderr b/src/test/ui/traits/predicate_can_apply-hang.stderr new file mode 100644 index 00000000000..49fe63b412a --- /dev/null +++ b/src/test/ui/traits/predicate_can_apply-hang.stderr @@ -0,0 +1,21 @@ +error[E0277]: can't compare `Vec<[[[B; 1]; 1]; 1]>` with `B` + --> $DIR/predicate_can_apply-hang.rs:1:38 + | +LL | fn f<B>(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq<B> { + | ^^^^^^^^^^^^^^^^^ no implementation for `Vec<[[[B; 1]; 1]; 1]> == B` +LL | +LL | x + | - return type was inferred to be `Vec<[[[B; 1]; 1]; 1]>` here + | + = help: the trait `PartialEq<B>` is not implemented for `Vec<[[[B; 1]; 1]; 1]>` + = help: the following other types implement trait `PartialEq<Rhs>`: + <Vec<T, A1> as PartialEq<Vec<U, A2>>> + <Vec<T, A> as PartialEq<&[U; N]>> + <Vec<T, A> as PartialEq<&[U]>> + <Vec<T, A> as PartialEq<&mut [U]>> + <Vec<T, A> as PartialEq<[U; N]>> + <Vec<T, A> as PartialEq<[U]>> + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/typeck/hang-in-overflow.rs b/src/test/ui/typeck/hang-in-overflow.rs new file mode 100644 index 00000000000..a8330c9b65c --- /dev/null +++ b/src/test/ui/typeck/hang-in-overflow.rs @@ -0,0 +1,19 @@ +// normalize-stderr-test "the requirement `.*`" -> "the requirement `...`" +// normalize-stderr-test "required for `.*` to implement `.*`" -> "required for `...` to implement `...`" +// normalize-stderr-test: ".*the full type name has been written to.*\n" -> "" + +// Currently this fatally aborts instead of hanging. +// Make sure at least that this doesn't turn into a hang. + +fn f() { + foo::<_>(); + //~^ ERROR overflow evaluating the requirement +} + +fn foo<B>() +where + Vec<[[[B; 1]; 1]; 1]>: PartialEq<B>, +{ +} + +fn main() {} diff --git a/src/test/ui/typeck/hang-in-overflow.stderr b/src/test/ui/typeck/hang-in-overflow.stderr new file mode 100644 index 00000000000..7a7b85b19b4 --- /dev/null +++ b/src/test/ui/typeck/hang-in-overflow.stderr @@ -0,0 +1,22 @@ +error[E0275]: overflow evaluating the requirement `...` + --> $DIR/hang-in-overflow.rs:9:5 + | +LL | foo::<_>(); + | ^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`hang_in_overflow`) + = note: required for `...` to implement `...` + = note: 127 redundant requirements hidden + = note: required for `...` to implement `...` +note: required by a bound in `foo` + --> $DIR/hang-in-overflow.rs:15:28 + | +LL | fn foo<B>() + | --- required by a bound in this +LL | where +LL | Vec<[[[B; 1]; 1]; 1]>: PartialEq<B>, + | ^^^^^^^^^^^^ required by this bound in `foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. |
