Skip to content

Commit 6af9f91

Browse files
committed
Auto merge of #51536 - davidtwco:nll-dyn-trait-underscore-error-improvements, r=nikomatsakis
NLL: bad error message when converting anonymous lifetime to `'static` Contributes to #46983. This PR doesn't introduce fantastic errors, but it should hopefully lay some groundwork for diagnostic improvements. r? @nikomatsakis
2 parents ef9a322 + c0c4741 commit 6af9f91

26 files changed

+559
-399
lines changed

src/librustc_mir/borrow_check/nll/constraint_generation.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
use borrow_check::borrow_set::BorrowSet;
1212
use borrow_check::location::LocationTable;
13+
use borrow_check::nll::ToRegionVid;
1314
use borrow_check::nll::facts::AllFacts;
1415
use borrow_check::nll::region_infer::{Cause, RegionInferenceContext};
15-
use borrow_check::nll::ToRegionVid;
16+
use borrow_check::nll::type_check::AtLocation;
1617
use rustc::hir;
1718
use rustc::infer::InferCtxt;
1819
use rustc::mir::visit::TyContext;
@@ -310,12 +311,10 @@ impl<'cx, 'cg, 'gcx, 'tcx> ConstraintGeneration<'cx, 'cg, 'gcx, 'tcx> {
310311
debug!("add_reborrow_constraint - base_ty = {:?}", base_ty);
311312
match base_ty.sty {
312313
ty::TyRef(ref_region, _, mutbl) => {
313-
let span = self.mir.source_info(location).span;
314314
self.regioncx.add_outlives(
315-
span,
315+
location.boring(),
316316
ref_region.to_region_vid(),
317317
borrow_region.to_region_vid(),
318-
location.successor_within_block(),
319318
);
320319

321320
if let Some(all_facts) = self.all_facts {

src/librustc_mir/borrow_check/nll/constraint_set.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::mir::Location;
1211
use rustc::ty::RegionVid;
1312
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
13+
use borrow_check::nll::type_check::Locations;
1414

1515
use std::fmt;
16-
use syntax_pos::Span;
1716
use std::ops::Deref;
1817

1918
#[derive(Clone, Default)]
@@ -24,8 +23,8 @@ crate struct ConstraintSet {
2423
impl ConstraintSet {
2524
pub fn push(&mut self, constraint: OutlivesConstraint) {
2625
debug!(
27-
"add_outlives({:?}: {:?} @ {:?}",
28-
constraint.sup, constraint.sub, constraint.point
26+
"add_outlives({:?}: {:?} @ {:?})",
27+
constraint.sup, constraint.sub, constraint.locations
2928
);
3029
if constraint.sup == constraint.sub {
3130
// 'a: 'a is pretty uninteresting
@@ -86,9 +85,6 @@ pub struct OutlivesConstraint {
8685
/// Region that must be outlived.
8786
pub sub: RegionVid,
8887

89-
/// At this location.
90-
pub point: Location,
91-
9288
/// Later on, we thread the constraints onto a linked list
9389
/// grouped by their `sub` field. So if you had:
9490
///
@@ -100,15 +96,15 @@ pub struct OutlivesConstraint {
10096
pub next: Option<ConstraintIndex>,
10197

10298
/// Where did this constraint arise?
103-
pub span: Span,
99+
pub locations: Locations,
104100
}
105101

106102
impl fmt::Debug for OutlivesConstraint {
107103
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
108104
write!(
109105
formatter,
110-
"({:?}: {:?} @ {:?}) due to {:?}",
111-
self.sup, self.sub, self.point, self.span
106+
"({:?}: {:?}) due to {:?}",
107+
self.sup, self.sub, self.locations
112108
)
113109
}
114110
}

src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
8282
let OutlivesConstraint {
8383
sup,
8484
sub,
85-
point,
86-
span,
85+
locations,
8786
next: _,
8887
} = constraint;
8988
with_msg(&format!(
90-
"{:?}: {:?} @ {:?} due to {:?}",
89+
"{:?}: {:?} due to {:?}",
9190
sup,
9291
sub,
93-
point,
94-
span
92+
locations,
9593
))?;
9694
}
9795

0 commit comments

Comments
 (0)