@@ -577,17 +577,33 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
577
577
for & tainted_region in & outgoing_taints {
578
578
match tainted_region {
579
579
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
581
582
// this snapshot:
582
583
//
583
584
// [skol] -> [tainted_region]
584
585
//
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).
591
607
//
592
608
// We used to force such `tainted_region` to be
593
609
// `'static`, but that leads to problems when
0 commit comments