Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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