@@ -5,6 +5,7 @@ use crate::traits::ObligationCtxt;
5
5
use rustc_errors:: ErrorGuaranteed ;
6
6
use rustc_infer:: infer:: region_constraints:: RegionConstraintData ;
7
7
use rustc_middle:: traits:: query:: NoSolution ;
8
+ use rustc_middle:: ty:: { TyCtxt , TypeFoldable } ;
8
9
use rustc_span:: source_map:: DUMMY_SP ;
9
10
use rustc_span:: Span ;
10
11
@@ -24,9 +25,10 @@ impl<F> CustomTypeOp<F> {
24
25
}
25
26
}
26
27
27
- impl < ' tcx , F , R : fmt :: Debug > super :: TypeOp < ' tcx > for CustomTypeOp < F >
28
+ impl < ' tcx , F , R > super :: TypeOp < ' tcx > for CustomTypeOp < F >
28
29
where
29
30
F : FnOnce ( & ObligationCtxt < ' _ , ' tcx > ) -> Result < R , NoSolution > ,
31
+ R : fmt:: Debug + TypeFoldable < TyCtxt < ' tcx > > ,
30
32
{
31
33
type Output = R ;
32
34
/// We can't do any custom error reporting for `CustomTypeOp`, so
@@ -57,12 +59,16 @@ impl<F> fmt::Debug for CustomTypeOp<F> {
57
59
58
60
/// Executes `op` and then scrapes out all the "old style" region
59
61
/// 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 > (
61
63
infcx : & InferCtxt < ' tcx > ,
62
64
op : impl FnOnce ( & ObligationCtxt < ' _ , ' tcx > ) -> Result < R , NoSolution > ,
63
65
name : & ' static str ,
64
66
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
+ {
66
72
// During NLL, we expect that nobody will register region
67
73
// obligations **except** as part of a custom type op (and, at the
68
74
// 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>(
91
97
}
92
98
} ) ?;
93
99
100
+ // Next trait solver performs operations locally, and normalize goals should resolve vars.
101
+ let value = infcx. resolve_vars_if_possible ( value) ;
102
+
94
103
let region_obligations = infcx. take_registered_region_obligations ( ) ;
95
104
let region_constraint_data = infcx. take_and_reset_region_constraints ( ) ;
96
105
let region_constraints = query_response:: make_query_region_constraints (
0 commit comments