Skip to content

Commit

Permalink
remove -Znll -- borrowck=mir implies nll now
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Apr 15, 2018
1 parent 818ae6f commit 45d281d
Show file tree
Hide file tree
Showing 136 changed files with 508 additions and 545 deletions.
8 changes: 4 additions & 4 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,28 +303,28 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
) {
debug!("report_region_errors(): {} errors to start", errors.len());

if will_later_be_reported_by_nll && self.tcx.nll() {
if will_later_be_reported_by_nll && self.tcx.use_mir() {
// With `#![feature(nll)]`, we want to present a nice user
// experience, so don't even mention the errors from the
// AST checker.
if self.tcx.features().nll {
return;
}

// But with -Znll, it's nice to have some note for later.
// But with nll, it's nice to have some note for later.
for error in errors {
match *error {
RegionResolutionError::ConcreteFailure(ref origin, ..)
| RegionResolutionError::GenericBoundFailure(ref origin, ..) => {
self.tcx
.sess
.span_warn(origin.span(), "not reporting region error due to -Znll");
.span_warn(origin.span(), "not reporting region error due to nll");
}

RegionResolutionError::SubSupConflict(ref rvo, ..) => {
self.tcx
.sess
.span_warn(rvo.span(), "not reporting region error due to -Znll");
.span_warn(rvo.span(), "not reporting region error due to nll");
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
useful for profiling / PGO."),
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
"choose which RELRO level to use"),
nll: bool = (false, parse_bool, [UNTRACKED],
"run the non-lexical lifetimes MIR pass"),
disable_nll_user_type_assert: bool = (false, parse_bool, [UNTRACKED],
"disable user provided type assertion in NLL"),
trans_time_graph: bool = (false, parse_bool, [UNTRACKED],
Expand Down
10 changes: 1 addition & 9 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1471,12 +1471,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self.on_disk_query_result_cache.serialize(self.global_tcx(), encoder)
}

/// If true, we should use NLL-style region checking instead of
/// lexical style.
pub fn nll(self) -> bool {
self.features().nll || self.sess.opts.debugging_opts.nll
}

/// If true, we should use the MIR-based borrowck (we may *also* use
/// the AST-based borrowck).
pub fn use_mir(self) -> bool {
Expand All @@ -1498,7 +1492,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
mode @ BorrowckMode::Compare => mode,

mode @ BorrowckMode::Ast => {
if self.nll() {
if self.features().nll {
BorrowckMode::Mir
} else {
mode
Expand All @@ -1512,8 +1506,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// MIR borrowck, but not when NLL is used. They are also consumed
/// by the validation stuff.
pub fn emit_end_regions(self) -> bool {
// FIXME(#46875) -- we should not emit end regions when NLL is enabled,
// but for now we can't stop doing so because it causes false positives
self.sess.opts.debugging_opts.emit_end_regions ||
self.sess.opts.debugging_opts.mir_emit_validate > 0 ||
self.use_mir()
Expand Down
14 changes: 1 addition & 13 deletions src/librustc_mir/borrow_check/borrow_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ use dataflow::indexes::BorrowIndex;
use rustc::mir::traversal;
use rustc::mir::visit::{PlaceContext, Visitor};
use rustc::mir::{self, Location, Mir, Place};
use rustc::ty::{self, Region, RegionKind, TyCtxt};
use rustc::ty::{Region, TyCtxt};
use rustc::util::nodemap::{FxHashMap, FxHashSet};
use rustc_data_structures::indexed_vec::IndexVec;
use std::fmt;
use std::hash::Hash;
use std::ops::Index;
use syntax_pos::Span;

crate struct BorrowSet<'tcx> {
/// The fundamental map relating bitvector indexes to the borrows
Expand All @@ -44,10 +43,6 @@ crate struct BorrowSet<'tcx> {

/// Map from local to all the borrows on that local
crate local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,

/// Maps regions to their corresponding source spans
/// Only contains ReScope()s as keys
crate region_span_map: FxHashMap<RegionKind, Span>,
}

impl<'tcx> Index<BorrowIndex> for BorrowSet<'tcx> {
Expand Down Expand Up @@ -103,7 +98,6 @@ impl<'tcx> BorrowSet<'tcx> {
activation_map: FxHashMap(),
region_map: FxHashMap(),
local_map: FxHashMap(),
region_span_map: FxHashMap(),
pending_activations: FxHashMap(),
};

Expand All @@ -130,7 +124,6 @@ impl<'tcx> BorrowSet<'tcx> {
activation_map: visitor.activation_map,
region_map: visitor.region_map,
local_map: visitor.local_map,
region_span_map: visitor.region_span_map,
}
}

Expand All @@ -150,7 +143,6 @@ struct GatherBorrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
activation_map: FxHashMap<Location, Vec<BorrowIndex>>,
region_map: FxHashMap<Region<'tcx>, FxHashSet<BorrowIndex>>,
local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,
region_span_map: FxHashMap<RegionKind, Span>,

/// When we encounter a 2-phase borrow statement, it will always
/// be assigning into a temporary TEMP:
Expand Down Expand Up @@ -276,10 +268,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
statement: &mir::Statement<'tcx>,
location: Location,
) {
if let mir::StatementKind::EndRegion(region_scope) = statement.kind {
self.region_span_map
.insert(ty::ReScope(region_scope), statement.source_info.span);
}
return self.super_statement(block, statement, location);
}
}
Expand Down
48 changes: 6 additions & 42 deletions src/librustc_mir/borrow_check/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
(place, span): (&Place<'tcx>, Span),
gen_borrow_kind: BorrowKind,
issued_borrow: &BorrowData<'tcx>,
end_issued_loan_span: Option<Span>,
) {
let issued_span = self.retrieve_borrow_span(issued_borrow);

Expand Down Expand Up @@ -297,7 +296,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
"it",
rgt,
"",
end_issued_loan_span,
None,
Origin::Mir,
)
}
Expand All @@ -309,7 +308,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
"",
issued_span,
"",
end_issued_loan_span,
None,
Origin::Mir,
)
}
Expand All @@ -319,7 +318,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
span,
&desc_place,
issued_span,
end_issued_loan_span,
None,
Origin::Mir,
)
}
Expand All @@ -331,7 +330,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
issued_span,
"it",
"",
end_issued_loan_span,
None,
Origin::Mir,
),

Expand All @@ -343,7 +342,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
lft,
issued_span,
"",
end_issued_loan_span,
None,
Origin::Mir,
)
}
Expand All @@ -356,7 +355,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
lft,
issued_span,
"",
end_issued_loan_span,
None,
Origin::Mir,
)
}
Expand Down Expand Up @@ -392,7 +391,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
borrow: &BorrowData<'tcx>,
drop_span: Span,
) {
let end_span = self.opt_region_end_span(&borrow.region);
let scope_tree = self.tcx.region_scope_tree(self.mir_def_id);
let root_place = self.prefixes(&borrow.borrowed_place, PrefixSet::All)
.last()
Expand Down Expand Up @@ -427,7 +425,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
drop_span,
borrow_span,
proper_span,
end_span,
);
}
(RegionKind::ReScope(_), None) => {
Expand All @@ -438,7 +435,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
drop_span,
borrow_span,
proper_span,
end_span,
);
}
(RegionKind::ReEarlyBound(_), Some(name))
Expand All @@ -454,7 +450,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
drop_span,
borrow_span,
proper_span,
end_span,
);
}
(RegionKind::ReEarlyBound(_), None)
Expand All @@ -469,7 +464,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
drop_span,
borrow_span,
proper_span,
end_span,
);
}
(RegionKind::ReLateBound(_, _), _)
Expand All @@ -491,7 +485,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
drop_span: Span,
borrow_span: Span,
_proper_span: Span,
end_span: Option<Span>,
) {
let tcx = self.tcx;
let mut err =
Expand All @@ -501,9 +494,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
drop_span,
format!("`{}` dropped here while still borrowed", name),
);
if let Some(end) = end_span {
err.span_label(end, "borrowed value needs to live until here");
}
self.explain_why_borrow_contains_point(context, borrow, &mut err);
err.emit();
}
Expand All @@ -516,7 +506,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
drop_span: Span,
_borrow_span: Span,
proper_span: Span,
end_span: Option<Span>,
) {
let tcx = self.tcx;
let mut err =
Expand All @@ -527,9 +516,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
"temporary value dropped here while still borrowed",
);
err.note("consider using a `let` binding to increase its lifetime");
if let Some(end) = end_span {
err.span_label(end, "temporary value needs to live until here");
}
self.explain_why_borrow_contains_point(context, borrow, &mut err);
err.emit();
}
Expand All @@ -543,7 +529,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
drop_span: Span,
borrow_span: Span,
_proper_span: Span,
_end_span: Option<Span>,
) {
debug!(
"report_unscoped_local_value_does_not_live_long_enough(\
Expand All @@ -558,16 +543,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
err.span_label(borrow_span, "borrowed value does not live long enough");
err.span_label(drop_span, "borrowed value only lives until here");

if !tcx.nll() {
tcx.note_and_explain_region(
scope_tree,
&mut err,
"borrowed value must be valid for ",
borrow.region,
"...",
);
}

self.explain_why_borrow_contains_point(context, borrow, &mut err);
err.emit();
}
Expand All @@ -580,7 +555,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
drop_span: Span,
_borrow_span: Span,
proper_span: Span,
_end_span: Option<Span>,
) {
debug!(
"report_unscoped_temporary_value_does_not_live_long_enough(\
Expand All @@ -595,16 +569,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
err.span_label(proper_span, "temporary value does not live long enough");
err.span_label(drop_span, "temporary value only lives until here");

if !tcx.nll() {
tcx.note_and_explain_region(
scope_tree,
&mut err,
"borrowed value must be valid for ",
borrow.region,
"...",
);
}

self.explain_why_borrow_contains_point(context, borrow, &mut err);
err.emit();
}
Expand Down
Loading

0 comments on commit 45d281d

Please sign in to comment.