@@ -41,27 +41,29 @@ pub struct InspectGoal<'a, 'tcx> {
41
41
goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
42
42
result : Result < Certainty , NoSolution > ,
43
43
evaluation_kind : inspect:: CanonicalGoalEvaluationKind < ' tcx > ,
44
- /// The expected term of a `NormalizesTo` goal. It gets
45
- /// replaced with an unconstrained inference variable when
46
- /// computing `NormalizesTo` goals and we return the nested
47
- /// goals to the caller, who also equates the actual term
48
- /// with the expected.
49
- ///
50
- /// This is an implementation detail of the trait solver and
51
- /// not something we want to leak to users. We therefore
52
- /// treat `NormalizesTo` goals as if they apply the expected
53
- /// type at the end of each candidate.
54
44
normalizes_to_term_hack : Option < NormalizesToTermHack < ' tcx > > ,
55
45
}
56
46
47
+ /// The expected term of a `NormalizesTo` goal gets replaced
48
+ /// with an unconstrained inference variable when computing
49
+ /// `NormalizesTo` goals and we return the nested goals to the
50
+ /// caller, who also equates the actual term with the expected.
51
+ ///
52
+ /// This is an implementation detail of the trait solver and
53
+ /// not something we want to leak to users. We therefore
54
+ /// treat `NormalizesTo` goals as if they apply the expected
55
+ /// type at the end of each candidate.
57
56
#[ derive( Copy , Clone ) ]
58
57
struct NormalizesToTermHack < ' tcx > {
59
58
term : ty:: Term < ' tcx > ,
60
59
unconstrained_term : ty:: Term < ' tcx > ,
61
60
}
62
61
63
62
impl < ' tcx > NormalizesToTermHack < ' tcx > {
64
- fn relate (
63
+ /// Relate the `term` with the new `unconstrained_term` created
64
+ /// when computing the proof tree for this `NormalizesTo` goals.
65
+ /// This handles nested obligations.
66
+ fn constrain (
65
67
self ,
66
68
infcx : & InferCtxt < ' tcx > ,
67
69
span : Span ,
@@ -166,7 +168,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
166
168
// FIXME: We ignore the expected term of `NormalizesTo` goals
167
169
// when computing the result of its candidates. This is
168
170
// scuffed.
169
- let _ = term_hack. relate ( infcx, span, param_env) ;
171
+ let _ = term_hack. constrain ( infcx, span, param_env) ;
170
172
}
171
173
172
174
instantiated_goals
@@ -326,7 +328,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
326
328
let result = evaluation. result . and_then ( |ok| {
327
329
if let Some ( term_hack) = normalizes_to_term_hack {
328
330
infcx
329
- . probe ( |_| term_hack. relate ( infcx, DUMMY_SP , uncanonicalized_goal. param_env ) )
331
+ . probe ( |_| term_hack. constrain ( infcx, DUMMY_SP , uncanonicalized_goal. param_env ) )
330
332
. map ( |certainty| ok. value . certainty . unify_with ( certainty) )
331
333
} else {
332
334
Ok ( ok. value . certainty )
0 commit comments