Skip to content

Commit cbe9328

Browse files
Do not need to account for overflow in predicate_can_apply
1 parent 604d521 commit cbe9328

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
25442544
let obligation =
25452545
Obligation::new(self.tcx, ObligationCause::dummy(), param_env, cleaned_pred);
25462546

2547-
self.predicate_may_hold(&obligation)
2547+
// We don't use `InferCtxt::predicate_may_hold` because that
2548+
// will re-run predicates that overflow locally, which ends up
2549+
// taking a really long time to compute.
2550+
self.evaluate_obligation(&obligation).map_or(false, |eval| eval.may_apply())
25482551
})
25492552
}
25502553

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn f<B>(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq<B> {
2+
//~^ ERROR can't compare `Vec<[[[B; 1]; 1]; 1]>` with `B`
3+
x
4+
}
5+
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0277]: can't compare `Vec<[[[B; 1]; 1]; 1]>` with `B`
2+
--> $DIR/predicate_can_apply-hang.rs:1:38
3+
|
4+
LL | fn f<B>(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq<B> {
5+
| ^^^^^^^^^^^^^^^^^ no implementation for `Vec<[[[B; 1]; 1]; 1]> == B`
6+
LL |
7+
LL | x
8+
| - return type was inferred to be `Vec<[[[B; 1]; 1]; 1]>` here
9+
|
10+
= help: the trait `PartialEq<B>` is not implemented for `Vec<[[[B; 1]; 1]; 1]>`
11+
= help: the following other types implement trait `PartialEq<Rhs>`:
12+
<Vec<T, A1> as PartialEq<Vec<U, A2>>>
13+
<Vec<T, A> as PartialEq<&[U; N]>>
14+
<Vec<T, A> as PartialEq<&[U]>>
15+
<Vec<T, A> as PartialEq<&mut [U]>>
16+
<Vec<T, A> as PartialEq<[U; N]>>
17+
<Vec<T, A> as PartialEq<[U]>>
18+
19+
error: aborting due to previous error
20+
21+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)