Skip to content

Commit 45d281d

Browse files
committed
remove -Znll -- borrowck=mir implies nll now
1 parent 818ae6f commit 45d281d

File tree

136 files changed

+508
-545
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+508
-545
lines changed

src/librustc/infer/error_reporting/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -303,28 +303,28 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
303303
) {
304304
debug!("report_region_errors(): {} errors to start", errors.len());
305305

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

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

324324
RegionResolutionError::SubSupConflict(ref rvo, ..) => {
325325
self.tcx
326326
.sess
327-
.span_warn(rvo.span(), "not reporting region error due to -Znll");
327+
.span_warn(rvo.span(), "not reporting region error due to nll");
328328
}
329329
}
330330
}

src/librustc/session/config.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12551255
useful for profiling / PGO."),
12561256
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
12571257
"choose which RELRO level to use"),
1258-
nll: bool = (false, parse_bool, [UNTRACKED],
1259-
"run the non-lexical lifetimes MIR pass"),
12601258
disable_nll_user_type_assert: bool = (false, parse_bool, [UNTRACKED],
12611259
"disable user provided type assertion in NLL"),
12621260
trans_time_graph: bool = (false, parse_bool, [UNTRACKED],

src/librustc/ty/context.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -1471,12 +1471,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14711471
self.on_disk_query_result_cache.serialize(self.global_tcx(), encoder)
14721472
}
14731473

1474-
/// If true, we should use NLL-style region checking instead of
1475-
/// lexical style.
1476-
pub fn nll(self) -> bool {
1477-
self.features().nll || self.sess.opts.debugging_opts.nll
1478-
}
1479-
14801474
/// If true, we should use the MIR-based borrowck (we may *also* use
14811475
/// the AST-based borrowck).
14821476
pub fn use_mir(self) -> bool {
@@ -1498,7 +1492,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14981492
mode @ BorrowckMode::Compare => mode,
14991493

15001494
mode @ BorrowckMode::Ast => {
1501-
if self.nll() {
1495+
if self.features().nll {
15021496
BorrowckMode::Mir
15031497
} else {
15041498
mode
@@ -1512,8 +1506,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
15121506
/// MIR borrowck, but not when NLL is used. They are also consumed
15131507
/// by the validation stuff.
15141508
pub fn emit_end_regions(self) -> bool {
1515-
// FIXME(#46875) -- we should not emit end regions when NLL is enabled,
1516-
// but for now we can't stop doing so because it causes false positives
15171509
self.sess.opts.debugging_opts.emit_end_regions ||
15181510
self.sess.opts.debugging_opts.mir_emit_validate > 0 ||
15191511
self.use_mir()

src/librustc_mir/borrow_check/borrow_set.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ use dataflow::indexes::BorrowIndex;
1313
use rustc::mir::traversal;
1414
use rustc::mir::visit::{PlaceContext, Visitor};
1515
use rustc::mir::{self, Location, Mir, Place};
16-
use rustc::ty::{self, Region, RegionKind, TyCtxt};
16+
use rustc::ty::{Region, TyCtxt};
1717
use rustc::util::nodemap::{FxHashMap, FxHashSet};
1818
use rustc_data_structures::indexed_vec::IndexVec;
1919
use std::fmt;
2020
use std::hash::Hash;
2121
use std::ops::Index;
22-
use syntax_pos::Span;
2322

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

4544
/// Map from local to all the borrows on that local
4645
crate local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,
47-
48-
/// Maps regions to their corresponding source spans
49-
/// Only contains ReScope()s as keys
50-
crate region_span_map: FxHashMap<RegionKind, Span>,
5146
}
5247

5348
impl<'tcx> Index<BorrowIndex> for BorrowSet<'tcx> {
@@ -103,7 +98,6 @@ impl<'tcx> BorrowSet<'tcx> {
10398
activation_map: FxHashMap(),
10499
region_map: FxHashMap(),
105100
local_map: FxHashMap(),
106-
region_span_map: FxHashMap(),
107101
pending_activations: FxHashMap(),
108102
};
109103

@@ -130,7 +124,6 @@ impl<'tcx> BorrowSet<'tcx> {
130124
activation_map: visitor.activation_map,
131125
region_map: visitor.region_map,
132126
local_map: visitor.local_map,
133-
region_span_map: visitor.region_span_map,
134127
}
135128
}
136129

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

155147
/// When we encounter a 2-phase borrow statement, it will always
156148
/// be assigning into a temporary TEMP:
@@ -276,10 +268,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
276268
statement: &mir::Statement<'tcx>,
277269
location: Location,
278270
) {
279-
if let mir::StatementKind::EndRegion(region_scope) = statement.kind {
280-
self.region_span_map
281-
.insert(ty::ReScope(region_scope), statement.source_info.span);
282-
}
283271
return self.super_statement(block, statement, location);
284272
}
285273
}

src/librustc_mir/borrow_check/error_reporting.rs

+6-42
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
263263
(place, span): (&Place<'tcx>, Span),
264264
gen_borrow_kind: BorrowKind,
265265
issued_borrow: &BorrowData<'tcx>,
266-
end_issued_loan_span: Option<Span>,
267266
) {
268267
let issued_span = self.retrieve_borrow_span(issued_borrow);
269268

@@ -297,7 +296,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
297296
"it",
298297
rgt,
299298
"",
300-
end_issued_loan_span,
299+
None,
301300
Origin::Mir,
302301
)
303302
}
@@ -309,7 +308,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
309308
"",
310309
issued_span,
311310
"",
312-
end_issued_loan_span,
311+
None,
313312
Origin::Mir,
314313
)
315314
}
@@ -319,7 +318,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
319318
span,
320319
&desc_place,
321320
issued_span,
322-
end_issued_loan_span,
321+
None,
323322
Origin::Mir,
324323
)
325324
}
@@ -331,7 +330,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
331330
issued_span,
332331
"it",
333332
"",
334-
end_issued_loan_span,
333+
None,
335334
Origin::Mir,
336335
),
337336

@@ -343,7 +342,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
343342
lft,
344343
issued_span,
345344
"",
346-
end_issued_loan_span,
345+
None,
347346
Origin::Mir,
348347
)
349348
}
@@ -356,7 +355,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
356355
lft,
357356
issued_span,
358357
"",
359-
end_issued_loan_span,
358+
None,
360359
Origin::Mir,
361360
)
362361
}
@@ -392,7 +391,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
392391
borrow: &BorrowData<'tcx>,
393392
drop_span: Span,
394393
) {
395-
let end_span = self.opt_region_end_span(&borrow.region);
396394
let scope_tree = self.tcx.region_scope_tree(self.mir_def_id);
397395
let root_place = self.prefixes(&borrow.borrowed_place, PrefixSet::All)
398396
.last()
@@ -427,7 +425,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
427425
drop_span,
428426
borrow_span,
429427
proper_span,
430-
end_span,
431428
);
432429
}
433430
(RegionKind::ReScope(_), None) => {
@@ -438,7 +435,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
438435
drop_span,
439436
borrow_span,
440437
proper_span,
441-
end_span,
442438
);
443439
}
444440
(RegionKind::ReEarlyBound(_), Some(name))
@@ -454,7 +450,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
454450
drop_span,
455451
borrow_span,
456452
proper_span,
457-
end_span,
458453
);
459454
}
460455
(RegionKind::ReEarlyBound(_), None)
@@ -469,7 +464,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
469464
drop_span,
470465
borrow_span,
471466
proper_span,
472-
end_span,
473467
);
474468
}
475469
(RegionKind::ReLateBound(_, _), _)
@@ -491,7 +485,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
491485
drop_span: Span,
492486
borrow_span: Span,
493487
_proper_span: Span,
494-
end_span: Option<Span>,
495488
) {
496489
let tcx = self.tcx;
497490
let mut err =
@@ -501,9 +494,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
501494
drop_span,
502495
format!("`{}` dropped here while still borrowed", name),
503496
);
504-
if let Some(end) = end_span {
505-
err.span_label(end, "borrowed value needs to live until here");
506-
}
507497
self.explain_why_borrow_contains_point(context, borrow, &mut err);
508498
err.emit();
509499
}
@@ -516,7 +506,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
516506
drop_span: Span,
517507
_borrow_span: Span,
518508
proper_span: Span,
519-
end_span: Option<Span>,
520509
) {
521510
let tcx = self.tcx;
522511
let mut err =
@@ -527,9 +516,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
527516
"temporary value dropped here while still borrowed",
528517
);
529518
err.note("consider using a `let` binding to increase its lifetime");
530-
if let Some(end) = end_span {
531-
err.span_label(end, "temporary value needs to live until here");
532-
}
533519
self.explain_why_borrow_contains_point(context, borrow, &mut err);
534520
err.emit();
535521
}
@@ -543,7 +529,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
543529
drop_span: Span,
544530
borrow_span: Span,
545531
_proper_span: Span,
546-
_end_span: Option<Span>,
547532
) {
548533
debug!(
549534
"report_unscoped_local_value_does_not_live_long_enough(\
@@ -558,16 +543,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
558543
err.span_label(borrow_span, "borrowed value does not live long enough");
559544
err.span_label(drop_span, "borrowed value only lives until here");
560545

561-
if !tcx.nll() {
562-
tcx.note_and_explain_region(
563-
scope_tree,
564-
&mut err,
565-
"borrowed value must be valid for ",
566-
borrow.region,
567-
"...",
568-
);
569-
}
570-
571546
self.explain_why_borrow_contains_point(context, borrow, &mut err);
572547
err.emit();
573548
}
@@ -580,7 +555,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
580555
drop_span: Span,
581556
_borrow_span: Span,
582557
proper_span: Span,
583-
_end_span: Option<Span>,
584558
) {
585559
debug!(
586560
"report_unscoped_temporary_value_does_not_live_long_enough(\
@@ -595,16 +569,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
595569
err.span_label(proper_span, "temporary value does not live long enough");
596570
err.span_label(drop_span, "temporary value only lives until here");
597571

598-
if !tcx.nll() {
599-
tcx.note_and_explain_region(
600-
scope_tree,
601-
&mut err,
602-
"borrowed value must be valid for ",
603-
borrow.region,
604-
"...",
605-
);
606-
}
607-
608572
self.explain_why_borrow_contains_point(context, borrow, &mut err);
609573
err.emit();
610574
}

0 commit comments

Comments
 (0)