Skip to content

Commit f323f9d

Browse files
committed
review
1 parent da969d4 commit f323f9d

File tree

1 file changed

+15
-13
lines changed
  • compiler/rustc_trait_selection/src/solve/inspect

1 file changed

+15
-13
lines changed

compiler/rustc_trait_selection/src/solve/inspect/analyse.rs

+15-13
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,29 @@ pub struct InspectGoal<'a, 'tcx> {
4141
goal: Goal<'tcx, ty::Predicate<'tcx>>,
4242
result: Result<Certainty, NoSolution>,
4343
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.
5444
normalizes_to_term_hack: Option<NormalizesToTermHack<'tcx>>,
5545
}
5646

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.
5756
#[derive(Copy, Clone)]
5857
struct NormalizesToTermHack<'tcx> {
5958
term: ty::Term<'tcx>,
6059
unconstrained_term: ty::Term<'tcx>,
6160
}
6261

6362
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(
6567
self,
6668
infcx: &InferCtxt<'tcx>,
6769
span: Span,
@@ -166,7 +168,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
166168
// FIXME: We ignore the expected term of `NormalizesTo` goals
167169
// when computing the result of its candidates. This is
168170
// scuffed.
169-
let _ = term_hack.relate(infcx, span, param_env);
171+
let _ = term_hack.constrain(infcx, span, param_env);
170172
}
171173

172174
instantiated_goals
@@ -326,7 +328,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
326328
let result = evaluation.result.and_then(|ok| {
327329
if let Some(term_hack) = normalizes_to_term_hack {
328330
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))
330332
.map(|certainty| ok.value.certainty.unify_with(certainty))
331333
} else {
332334
Ok(ok.value.certainty)

0 commit comments

Comments
 (0)