Skip to content

Commit 94a9c62

Browse files
committed
add unreported error variant
1 parent 43888e8 commit 94a9c62

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

src/librustc_mir/borrow_check/diagnostics/region_errors.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ crate enum RegionErrorKind<'tcx> {
107107
/// The region that should be shorter, but we can't prove it
108108
shorter_fr: RegionVid,
109109
},
110+
111+
/// The same as `RegionError`, but this is an unreported error. We currently only report the
112+
/// first error encountered and leave the rest unreported so as not to overwhelm the user.
113+
UnreportedError {
114+
/// The origin of the region
115+
fr_origin: NLLRegionVariableOrigin,
116+
/// The region that should outlive `shorter_fr`
117+
longer_fr: RegionVid,
118+
/// The region that should be shorter, but we can't prove it
119+
shorter_fr: RegionVid,
120+
}
110121
}
111122

112123
/// Various pieces of state used when reporting borrow checker errors.

src/librustc_mir/borrow_check/mod.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,24 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16641664
db.buffer(&mut self.errors_buffer);
16651665

16661666
// Emit outlives suggestions
1667-
//outlives_suggestion.add_suggestion(body, self, infcx, errors_buffer, region_naming);
1667+
outlives_suggestion.add_suggestion(
1668+
&self.body,
1669+
&self.nonlexical_regioncx,
1670+
self.infcx,
1671+
&mut self.errors_buffer,
1672+
&mut region_naming
1673+
);
1674+
}
1675+
1676+
RegionErrorKind::UnreportedError {
1677+
longer_fr, shorter_fr,
1678+
fr_origin: _,
1679+
} => {
1680+
// FIXME: currently we do nothing with these, but perhaps we can do better?
1681+
debug!(
1682+
"Unreported region error: can't prove that {:?}: {:?}",
1683+
longer_fr, shorter_fr
1684+
);
16681685
}
16691686
}
16701687
}

src/librustc_mir/borrow_check/region_infer/mod.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,15 +1467,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
14671467
propagated_outlives_requirements,
14681468
errors_buffer,
14691469
) {
1470-
// continuing to iterate just reports more errors than necessary
1471-
//
1472-
// FIXME It would also allow us to report more Outlives Suggestions, though, so
1473-
// it's not clear that that's a bad thing. Somebody should try commenting out this
1474-
// line and see it is actually a regression.
1475-
//
1476-
// TODO(mark-i-m): perhaps we could add them to the `RegionErrors` with a flag that
1477-
// says "don't report me"?
1478-
return;
1470+
// We only report the first region error. Subsequent errors are hidden so as not to
1471+
// overwhelm the user, but we do record them so as to potentially print better
1472+
// diagnostics elsewhere...
1473+
errors_buffer.push(RegionErrorKind::UnreportedError {
1474+
longer_fr, shorter_fr,
1475+
fr_origin: NLLRegionVariableOrigin::FreeRegion,
1476+
});
14791477
}
14801478
}
14811479
}

0 commit comments

Comments
 (0)