Skip to content

Commit 82c1435

Browse files
committed
do not limit NiceRegionError to SubSupConflict or ConcreteFailure
1 parent 442ae7f commit 82c1435

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
4545
///
4646
/// It will later be extended to trait objects.
4747
pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorReported> {
48-
let (span, sub, sup) = self.regions();
48+
let (span, sub, sup) = self.regions()?;
4949

5050
// Determine whether the sub and sup consist of both anonymous (elided) regions.
5151
let anon_reg_sup = self.tcx().is_suitable_region(sup)?;

src/librustc/infer/error_reporting/nice_region_error/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ mod util;
1717

1818
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
1919
pub fn try_report_nice_region_error(&self, error: &RegionResolutionError<'tcx>) -> bool {
20-
match *error {
21-
ConcreteFailure(..) | SubSupConflict(..) => {}
22-
_ => return false, // inapplicable
23-
}
24-
2520
if let Some(tables) = self.in_progress_tables {
2621
let tables = tables.borrow();
2722
NiceRegionError::new(self, error.clone(), Some(&tables)).try_report().is_some()
@@ -79,13 +74,14 @@ impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> {
7974
.or_else(|| self.try_report_impl_not_conforming_to_trait())
8075
}
8176

82-
pub fn regions(&self) -> (Span, ty::Region<'tcx>, ty::Region<'tcx>) {
77+
pub fn regions(&self) -> Option<(Span, ty::Region<'tcx>, ty::Region<'tcx>)> {
8378
match (&self.error, self.regions) {
84-
(Some(ConcreteFailure(origin, sub, sup)), None) => (origin.span(), sub, sup),
85-
(Some(SubSupConflict(_, _, origin, sub, _, sup)), None) => (origin.span(), sub, sup),
86-
(None, Some((span, sub, sup))) => (span, sub, sup),
87-
(Some(_), Some(_)) => panic!("incorrectly built NiceRegionError"),
88-
_ => panic!("trying to report on an incorrect lifetime failure"),
79+
(Some(ConcreteFailure(origin, sub, sup)), None) => Some((origin.span(), sub, sup)),
80+
(Some(SubSupConflict(_, _, origin, sub, _, sup)), None) => {
81+
Some((origin.span(), sub, sup))
82+
}
83+
(None, Some((span, sub, sup))) => Some((span, sub, sup)),
84+
_ => None,
8985
}
9086
}
9187
}

src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
99
/// When given a `ConcreteFailure` for a function with parameters containing a named region and
1010
/// an anonymous region, emit an descriptive diagnostic error.
1111
pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<'a>> {
12-
let (span, sub, sup) = self.regions();
12+
let (span, sub, sup) = self.regions()?;
1313

1414
debug!(
1515
"try_report_named_anon_conflict(sub={:?}, sup={:?}, error={:?})",

0 commit comments

Comments
 (0)