From 69a07f796c1b35875c94f5f6b4d635cb732db271 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 26 Nov 2022 21:57:04 +0000 Subject: [PATCH 1/3] Revert "Add fatal overflow test" This reverts commit 9decfff6f87d3e5760fd61375c3d27fa45a83e52. --- src/test/ui/typeck/hang-in-overflow.rs | 19 ------------------- src/test/ui/typeck/hang-in-overflow.stderr | 22 ---------------------- 2 files changed, 41 deletions(-) delete mode 100644 src/test/ui/typeck/hang-in-overflow.rs delete mode 100644 src/test/ui/typeck/hang-in-overflow.stderr diff --git a/src/test/ui/typeck/hang-in-overflow.rs b/src/test/ui/typeck/hang-in-overflow.rs deleted file mode 100644 index a8330c9b65c..00000000000 --- a/src/test/ui/typeck/hang-in-overflow.rs +++ /dev/null @@ -1,19 +0,0 @@ -// 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() -where - Vec<[[[B; 1]; 1]; 1]>: PartialEq, -{ -} - -fn main() {} diff --git a/src/test/ui/typeck/hang-in-overflow.stderr b/src/test/ui/typeck/hang-in-overflow.stderr deleted file mode 100644 index 7a7b85b19b4..00000000000 --- a/src/test/ui/typeck/hang-in-overflow.stderr +++ /dev/null @@ -1,22 +0,0 @@ -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() - | --- required by a bound in this -LL | where -LL | Vec<[[[B; 1]; 1]; 1]>: PartialEq, - | ^^^^^^^^^^^^ required by this bound in `foo` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. From c285218f43027a9257d619b42643a8a10ba6af7d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 26 Nov 2022 22:15:43 +0000 Subject: [PATCH 2/3] Revert "Drive-by: Don't manually call evaluate_obligation_no_overflow" This reverts commit a884a9e634b827781e77bddf4082f1196301d86f. --- .../src/traits/error_reporting/suggestions.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index da6ca30cc9a..50816d12025 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1336,8 +1336,9 @@ fn suggest_change_mut( obligation.param_env, trait_pred_and_suggested_ty, ); - let suggested_ty_would_satisfy_obligation = - self.predicate_must_hold_modulo_regions(&new_obligation); + let suggested_ty_would_satisfy_obligation = self + .evaluate_obligation_no_overflow(&new_obligation) + .must_apply_modulo_regions(); if suggested_ty_would_satisfy_obligation { let sp = self .tcx From 4149923ff0a948161e85544c2f68dfd828ddb382 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 26 Nov 2022 22:15:51 +0000 Subject: [PATCH 3/3] Revert "Do not need to account for overflow in predicate_can_apply" This reverts commit cbe932801892da06688b53638622be1c8a1c8974. --- .../src/traits/error_reporting/mod.rs | 5 +---- .../ui/traits/predicate_can_apply-hang.rs | 6 ------ .../ui/traits/predicate_can_apply-hang.stderr | 21 ------------------- 3 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 src/test/ui/traits/predicate_can_apply-hang.rs delete mode 100644 src/test/ui/traits/predicate_can_apply-hang.stderr diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 4ac53f6302f..e06ee851264 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -2544,10 +2544,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { let obligation = Obligation::new(self.tcx, ObligationCause::dummy(), param_env, cleaned_pred); - // We don't use `InferCtxt::predicate_may_hold` because that - // will re-run predicates that overflow locally, which ends up - // taking a really long time to compute. - self.evaluate_obligation(&obligation).map_or(false, |eval| eval.may_apply()) + self.predicate_may_hold(&obligation) }) } diff --git a/src/test/ui/traits/predicate_can_apply-hang.rs b/src/test/ui/traits/predicate_can_apply-hang.rs deleted file mode 100644 index 5f01645da52..00000000000 --- a/src/test/ui/traits/predicate_can_apply-hang.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn f(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq { - //~^ 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 deleted file mode 100644 index 49fe63b412a..00000000000 --- a/src/test/ui/traits/predicate_can_apply-hang.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0277]: can't compare `Vec<[[[B; 1]; 1]; 1]>` with `B` - --> $DIR/predicate_can_apply-hang.rs:1:38 - | -LL | fn f(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq { - | ^^^^^^^^^^^^^^^^^ 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` is not implemented for `Vec<[[[B; 1]; 1]; 1]>` - = help: the following other types implement trait `PartialEq`: - as PartialEq>> - as PartialEq<&[U; N]>> - as PartialEq<&[U]>> - as PartialEq<&mut [U]>> - as PartialEq<[U; N]>> - as PartialEq<[U]>> - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`.