Do not need to account for overflow in predicate_can_apply
This commit is contained in:
parent
604d52108e
commit
cbe9328018
@ -2544,7 +2544,10 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let obligation =
|
||||
Obligation::new(self.tcx, ObligationCause::dummy(), param_env, cleaned_pred);
|
||||
|
||||
self.predicate_may_hold(&obligation)
|
||||
// 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())
|
||||
})
|
||||
}
|
||||
|
||||
|
6
src/test/ui/traits/predicate_can_apply-hang.rs
Normal file
6
src/test/ui/traits/predicate_can_apply-hang.rs
Normal file
@ -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() {}
|
21
src/test/ui/traits/predicate_can_apply-hang.stderr
Normal file
21
src/test/ui/traits/predicate_can_apply-hang.stderr
Normal file
@ -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`.
|
Loading…
Reference in New Issue
Block a user