@@ -5,6 +5,7 @@ use crate::traits::ObligationCtxt;
55use rustc_errors:: ErrorGuaranteed ;
66use rustc_infer:: infer:: region_constraints:: RegionConstraintData ;
77use rustc_middle:: traits:: query:: NoSolution ;
8+ use rustc_middle:: ty:: { TyCtxt , TypeFoldable } ;
89use rustc_span:: source_map:: DUMMY_SP ;
910use rustc_span:: Span ;
1011
@@ -24,9 +25,10 @@ impl<F> CustomTypeOp<F> {
2425 }
2526}
2627
27- impl < ' tcx , F , R : fmt :: Debug > super :: TypeOp < ' tcx > for CustomTypeOp < F >
28+ impl < ' tcx , F , R > super :: TypeOp < ' tcx > for CustomTypeOp < F >
2829where
2930 F : FnOnce ( & ObligationCtxt < ' _ , ' tcx > ) -> Result < R , NoSolution > ,
31+ R : fmt:: Debug + TypeFoldable < TyCtxt < ' tcx > > ,
3032{
3133 type Output = R ;
3234 /// We can't do any custom error reporting for `CustomTypeOp`, so
@@ -57,12 +59,16 @@ impl<F> fmt::Debug for CustomTypeOp<F> {
5759
5860/// Executes `op` and then scrapes out all the "old style" region
5961/// constraints that result, creating query-region-constraints.
60- pub fn scrape_region_constraints < ' tcx , Op : super :: TypeOp < ' tcx , Output = R > , R > (
62+ pub fn scrape_region_constraints < ' tcx , Op , R > (
6163 infcx : & InferCtxt < ' tcx > ,
6264 op : impl FnOnce ( & ObligationCtxt < ' _ , ' tcx > ) -> Result < R , NoSolution > ,
6365 name : & ' static str ,
6466 span : Span ,
65- ) -> Result < ( TypeOpOutput < ' tcx , Op > , RegionConstraintData < ' tcx > ) , ErrorGuaranteed > {
67+ ) -> Result < ( TypeOpOutput < ' tcx , Op > , RegionConstraintData < ' tcx > ) , ErrorGuaranteed >
68+ where
69+ R : TypeFoldable < TyCtxt < ' tcx > > ,
70+ Op : super :: TypeOp < ' tcx , Output = R > ,
71+ {
6672 // During NLL, we expect that nobody will register region
6773 // obligations **except** as part of a custom type op (and, at the
6874 // end of each custom type op, we scrape out the region
@@ -91,6 +97,9 @@ pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
9197 }
9298 } ) ?;
9399
100+ // Next trait solver performs operations locally, and normalize goals should resolve vars.
101+ let value = infcx. resolve_vars_if_possible ( value) ;
102+
94103 let region_obligations = infcx. take_registered_region_obligations ( ) ;
95104 let region_constraint_data = infcx. take_and_reset_region_constraints ( ) ;
96105 let region_constraints = query_response:: make_query_region_constraints (
0 commit comments