Skip to content

Commit e5a1f48

Browse files
committed
fix outlives suggestions
1 parent 3902e56 commit e5a1f48

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/librustc_mir/borrow_check/diagnostics/outlives_suggestion.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ impl OutlivesSuggestionBuilder<'a> {
250250

251251
// If there is only one constraint to suggest, then we already suggested it in the
252252
// intermediate suggestion above.
253-
if self.constraints_to_add.len() == 1 {
253+
if self.constraints_to_add.len() == 1
254+
&& self.constraints_to_add.values().next().unwrap().len() == 1
255+
{
254256
debug!("Only 1 suggestion. Skipping.");
255257
return;
256258
}

src/librustc_mir/borrow_check/mod.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,29 +1664,31 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16641664
);
16651665

16661666
db.buffer(&mut self.errors_buffer);
1667-
1668-
// Emit outlives suggestions
1669-
outlives_suggestion.add_suggestion(
1670-
&self.body,
1671-
&self.nonlexical_regioncx,
1672-
self.infcx,
1673-
&mut self.errors_buffer,
1674-
&mut region_naming
1675-
);
16761667
}
16771668

16781669
RegionErrorKind::UnreportedError {
16791670
longer_fr, shorter_fr,
16801671
fr_origin: _,
16811672
} => {
16821673
// FIXME: currently we do nothing with these, but perhaps we can do better?
1674+
// FIXME: try collecting these constraints on the outlives suggestion builder.
1675+
// Does it make the suggestions any better?
16831676
debug!(
16841677
"Unreported region error: can't prove that {:?}: {:?}",
16851678
longer_fr, shorter_fr
16861679
);
16871680
}
16881681
}
16891682
}
1683+
1684+
// Emit one outlives suggestions for each MIR def we borrowck
1685+
outlives_suggestion.add_suggestion(
1686+
&self.body,
1687+
&self.nonlexical_regioncx,
1688+
self.infcx,
1689+
&mut self.errors_buffer,
1690+
&mut region_naming
1691+
);
16901692
}
16911693
}
16921694

0 commit comments

Comments
 (0)