Skip to content

Commit

Permalink
Auto merge of rust-lang#51536 - davidtwco:nll-dyn-trait-underscore-er…
Browse files Browse the repository at this point in the history
…ror-improvements, r=nikomatsakis

NLL: bad error message when converting anonymous lifetime to `'static`

Contributes to rust-lang#46983. This PR doesn't introduce fantastic errors, but it should hopefully lay some groundwork for diagnostic improvements.
r? @nikomatsakis
  • Loading branch information
bors committed Jul 1, 2018
2 parents ef9a322 + c0c4741 commit 6af9f91
Show file tree
Hide file tree
Showing 26 changed files with 559 additions and 399 deletions.
7 changes: 3 additions & 4 deletions src/librustc_mir/borrow_check/nll/constraint_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

use borrow_check::borrow_set::BorrowSet;
use borrow_check::location::LocationTable;
use borrow_check::nll::ToRegionVid;
use borrow_check::nll::facts::AllFacts;
use borrow_check::nll::region_infer::{Cause, RegionInferenceContext};
use borrow_check::nll::ToRegionVid;
use borrow_check::nll::type_check::AtLocation;
use rustc::hir;
use rustc::infer::InferCtxt;
use rustc::mir::visit::TyContext;
Expand Down Expand Up @@ -310,12 +311,10 @@ impl<'cx, 'cg, 'gcx, 'tcx> ConstraintGeneration<'cx, 'cg, 'gcx, 'tcx> {
debug!("add_reborrow_constraint - base_ty = {:?}", base_ty);
match base_ty.sty {
ty::TyRef(ref_region, _, mutbl) => {
let span = self.mir.source_info(location).span;
self.regioncx.add_outlives(
span,
location.boring(),
ref_region.to_region_vid(),
borrow_region.to_region_vid(),
location.successor_within_block(),
);

if let Some(all_facts) = self.all_facts {
Expand Down
16 changes: 6 additions & 10 deletions src/librustc_mir/borrow_check/nll/constraint_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use rustc::mir::Location;
use rustc::ty::RegionVid;
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use borrow_check::nll::type_check::Locations;

use std::fmt;
use syntax_pos::Span;
use std::ops::Deref;

#[derive(Clone, Default)]
Expand All @@ -24,8 +23,8 @@ crate struct ConstraintSet {
impl ConstraintSet {
pub fn push(&mut self, constraint: OutlivesConstraint) {
debug!(
"add_outlives({:?}: {:?} @ {:?}",
constraint.sup, constraint.sub, constraint.point
"add_outlives({:?}: {:?} @ {:?})",
constraint.sup, constraint.sub, constraint.locations
);
if constraint.sup == constraint.sub {
// 'a: 'a is pretty uninteresting
Expand Down Expand Up @@ -86,9 +85,6 @@ pub struct OutlivesConstraint {
/// Region that must be outlived.
pub sub: RegionVid,

/// At this location.
pub point: Location,

/// Later on, we thread the constraints onto a linked list
/// grouped by their `sub` field. So if you had:
///
Expand All @@ -100,15 +96,15 @@ pub struct OutlivesConstraint {
pub next: Option<ConstraintIndex>,

/// Where did this constraint arise?
pub span: Span,
pub locations: Locations,
}

impl fmt::Debug for OutlivesConstraint {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(
formatter,
"({:?}: {:?} @ {:?}) due to {:?}",
self.sup, self.sub, self.point, self.span
"({:?}: {:?}) due to {:?}",
self.sup, self.sub, self.locations
)
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let OutlivesConstraint {
sup,
sub,
point,
span,
locations,
next: _,
} = constraint;
with_msg(&format!(
"{:?}: {:?} @ {:?} due to {:?}",
"{:?}: {:?} due to {:?}",
sup,
sub,
point,
span
locations,
))?;
}

Expand Down
Loading

0 comments on commit 6af9f91

Please sign in to comment.