|
62 | 62 | use crate::infer::outlives::components::{push_outlives_components, Component};
|
63 | 63 | use crate::infer::outlives::env::RegionBoundPairs;
|
64 | 64 | use crate::infer::outlives::verify::VerifyBoundCx;
|
| 65 | +use crate::infer::resolve::OpportunisticRegionResolver; |
65 | 66 | use crate::infer::{
|
66 | 67 | self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, UndoLog, VerifyBound,
|
67 | 68 | };
|
68 | 69 | use crate::traits::{ObligationCause, ObligationCauseCode};
|
69 | 70 | use rustc_data_structures::undo_log::UndoLogs;
|
70 | 71 | use rustc_middle::mir::ConstraintCategory;
|
71 | 72 | use rustc_middle::traits::query::NoSolution;
|
72 |
| -use rustc_middle::ty::{self, GenericArgsRef, Region, Ty, TyCtxt, TypeVisitableExt}; |
| 73 | +use rustc_middle::ty::{ |
| 74 | + self, GenericArgsRef, Region, Ty, TyCtxt, TypeFoldable as _, TypeVisitableExt, |
| 75 | +}; |
73 | 76 | use rustc_middle::ty::{GenericArgKind, PolyTypeOutlivesPredicate};
|
74 | 77 | use rustc_span::DUMMY_SP;
|
75 | 78 | use smallvec::smallvec;
|
@@ -176,6 +179,11 @@ impl<'tcx> InferCtxt<'tcx> {
|
176 | 179 | .map_err(|NoSolution| (outlives, origin.clone()))?
|
177 | 180 | .no_bound_vars()
|
178 | 181 | .expect("started with no bound vars, should end with no bound vars");
|
| 182 | + // `TypeOutlives` is structural, so we should try to opportunistically resolve all |
| 183 | + // region vids before processing regions, so we have a better chance to match clauses |
| 184 | + // in our param-env. |
| 185 | + let (sup_type, sub_region) = |
| 186 | + (sup_type, sub_region).fold_with(&mut OpportunisticRegionResolver::new(self)); |
179 | 187 |
|
180 | 188 | debug!(?sup_type, ?sub_region, ?origin);
|
181 | 189 |
|
|
0 commit comments