Skip to content

Commit 0ec6e29

Browse files
committed
clarify comment
1 parent 81c6e18 commit 0ec6e29

File tree

1 file changed

+23
-7
lines changed
  • src/librustc/infer/higher_ranked

1 file changed

+23
-7
lines changed

src/librustc/infer/higher_ranked/mod.rs

+23-7
Original file line numberDiff line numberDiff line change
@@ -577,17 +577,33 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
577577
for &tainted_region in &outgoing_taints {
578578
match tainted_region {
579579
ty::ReVar(vid) if new_vars.contains(&vid) => {
580-
// Some region variable that doesn't escape
580+
// There is a path from a skolemized variable
581+
// to some region variable that doesn't escape
581582
// this snapshot:
582583
//
583584
// [skol] -> [tainted_region]
584585
//
585-
// We can ignore this. We know that if it has
586-
// outgoing edges to any other regions, then those
587-
// regions must be 'static. If it has incoming
588-
// edges from other regions, we could therefore
589-
// infer it to 'static, and those edges would be
590-
// satisfied.
586+
// We can ignore this. The reasoning relies on
587+
// the fact that the preivous loop
588+
// completed. There are two possible cases
589+
// here.
590+
//
591+
// - `tainted_region` eventually reaches a
592+
// skolemized variable, which *must* be `skol`
593+
// (because otherwise we would have already
594+
// returned `Err`). In that case,
595+
// `tainted_region` could be inferred to `skol`.
596+
//
597+
// - `tainted_region` never reaches a
598+
// skolemized variable. In that case, we can
599+
// safely choose `'static` as an upper bound
600+
// incoming edges. This is a conservative
601+
// choice -- the LUB might be one of the
602+
// incoming skolemized variables, which we
603+
// might know by ambient bounds. We can
604+
// consider a more clever choice of upper
605+
// bound later (modulo some theoretical
606+
// breakage).
591607
//
592608
// We used to force such `tainted_region` to be
593609
// `'static`, but that leads to problems when

0 commit comments

Comments
 (0)