diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 157614f847a1..194b014c97b2 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1312,8 +1312,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "choose which RELRO level to use"), nll: bool = (false, parse_bool, [UNTRACKED], "run the non-lexical lifetimes MIR pass"), - nll_dump_cause: bool = (false, parse_bool, [UNTRACKED], - "dump cause information when reporting errors from NLL"), trans_time_graph: bool = (false, parse_bool, [UNTRACKED], "generate a graphical HTML report of time spent in trans and LLVM"), thinlto: Option = (None, parse_opt_bool, [TRACKED], diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 5e9eeb973007..067e480bd60e 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -476,13 +476,6 @@ impl Session { *(self.features.borrow_mut()) = Some(features); } - /// If true, we should gather causal information during NLL - /// checking. This will eventually be the normal thing, but right - /// now it is too unoptimized. - pub fn nll_dump_cause(&self) -> bool { - self.opts.debugging_opts.nll_dump_cause - } - /// Calculates the flavor of LTO to use for this compilation. pub fn lto(&self) -> config::Lto { // If our target has codegen requirements ignore the command line diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index 3ffb4370359b..2151592fd663 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -72,8 +72,6 @@ pub struct RegionInferenceContext<'tcx> { universal_regions: UniversalRegions<'tcx>, } -struct TrackCauses(bool); - struct RegionDefinition<'tcx> { /// Why we created this variable. Mostly these will be /// `RegionVariableOrigin::NLL`, but some variables get created @@ -250,15 +248,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { .map(|origin| RegionDefinition::new(origin)) .collect(); - let nll_dump_cause = ty::tls::with(|tcx| tcx.sess.nll_dump_cause()); - let mut result = Self { definitions, elements: elements.clone(), liveness_constraints: RegionValues::new( elements, num_region_variables, - TrackCauses(nll_dump_cause), ), inferred_values: None, constraints: Vec::new(), diff --git a/src/librustc_mir/borrow_check/nll/region_infer/values.rs b/src/librustc_mir/borrow_check/nll/region_infer/values.rs index e6f2a43bfc8f..74ee04e0fb15 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/values.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/values.rs @@ -17,7 +17,7 @@ use rustc::mir::{BasicBlock, Location, Mir}; use rustc::ty::RegionVid; use syntax::codemap::Span; -use super::{Cause, CauseExt, TrackCauses}; +use super::{Cause, CauseExt}; /// Maps between the various kinds of elements of a region value to /// the internal indices that w use. @@ -202,7 +202,6 @@ impl RegionValues { pub(super) fn new( elements: &Rc, num_region_variables: usize, - track_causes: TrackCauses, ) -> Self { assert!( elements.num_universal_regions <= num_region_variables, @@ -215,11 +214,7 @@ impl RegionValues { RegionVid::new(num_region_variables), RegionElementIndex::new(elements.num_elements()), ), - causes: if track_causes.0 { - Some(CauseMap::default()) - } else { - None - }, + causes: Some(CauseMap::default()), } } diff --git a/src/test/ui/issue-45157.stderr b/src/test/ui/issue-45157.stderr index 3ce93da6ad55..bec91f7f70de 100644 --- a/src/test/ui/issue-45157.stderr +++ b/src/test/ui/issue-45157.stderr @@ -6,6 +6,9 @@ LL | let mref = &mut u.s.a; ... LL | let nref = &u.z.c; | ^^^^^^ immutable borrow occurs here +LL | //~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502] +LL | println!("{} {}", mref, nref) + | ---- borrow later used here error[E0502]: cannot borrow `u.s.a` as mutable because it is also borrowed as immutable --> $DIR/issue-45157.rs:39:27 @@ -14,7 +17,9 @@ LL | let nref = &u.z.c; | ------ immutable borrow occurs here LL | //~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502] LL | println!("{} {}", mref, nref) - | ^^^^ mutable borrow occurs here + | ^^^^ ---- borrow later used here + | | + | mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/borrowed-local-error.rs b/src/test/ui/nll/borrowed-local-error.rs index 785a38da9598..084d0c159ef3 100644 --- a/src/test/ui/nll/borrowed-local-error.rs +++ b/src/test/ui/nll/borrowed-local-error.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: -Znll-dump-cause - #![feature(nll)] fn gimme(x: &(u32,)) -> &u32 { diff --git a/src/test/ui/nll/borrowed-local-error.stderr b/src/test/ui/nll/borrowed-local-error.stderr index 3bc197855482..24964f651f79 100644 --- a/src/test/ui/nll/borrowed-local-error.stderr +++ b/src/test/ui/nll/borrowed-local-error.stderr @@ -1,5 +1,5 @@ error[E0597]: `v` does not live long enough - --> $DIR/borrowed-local-error.rs:22:9 + --> $DIR/borrowed-local-error.rs:20:9 | LL | let x = gimme({ | _____________- diff --git a/src/test/ui/nll/borrowed-match-issue-45045.stderr b/src/test/ui/nll/borrowed-match-issue-45045.stderr index 144eba8cb769..a80bc686e34a 100644 --- a/src/test/ui/nll/borrowed-match-issue-45045.stderr +++ b/src/test/ui/nll/borrowed-match-issue-45045.stderr @@ -10,6 +10,8 @@ LL | | //~^ cannot use `e` because it was mutably borrowed [E0503] LL | | Xyz::B => println!("b"), LL | | }; | |_____^ use of borrowed `e` +LL | *g = Xyz::B; + | ----------- borrow later used here error[E0503]: cannot use `e` because it was mutably borrowed --> $DIR/borrowed-match-issue-45045.rs:25:9 @@ -19,6 +21,9 @@ LL | let f = &mut e; ... LL | Xyz::A => println!("a"), | ^^^^^^ use of borrowed `e` +... +LL | *g = Xyz::B; + | ----------- borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/borrowed-referent-issue-38899.stderr b/src/test/ui/nll/borrowed-referent-issue-38899.stderr index 91f817832975..675f85ecb4dd 100644 --- a/src/test/ui/nll/borrowed-referent-issue-38899.stderr +++ b/src/test/ui/nll/borrowed-referent-issue-38899.stderr @@ -6,6 +6,9 @@ LL | let x = &mut block; LL | println!("{}", x.current); LL | let p: &'a u8 = &*block.current; | ^^^^^^^^^^^^^^^ immutable borrow occurs here +LL | //~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable +LL | drop(x); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/nll/borrowed-temporary-error.rs b/src/test/ui/nll/borrowed-temporary-error.rs index e1a6112d173f..7aad7205a52a 100644 --- a/src/test/ui/nll/borrowed-temporary-error.rs +++ b/src/test/ui/nll/borrowed-temporary-error.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: -Znll-dump-cause - #![feature(nll)] fn gimme(x: &(u32,)) -> &u32 { diff --git a/src/test/ui/nll/borrowed-temporary-error.stderr b/src/test/ui/nll/borrowed-temporary-error.stderr index f5cb1dccc378..575d9b5a62d7 100644 --- a/src/test/ui/nll/borrowed-temporary-error.stderr +++ b/src/test/ui/nll/borrowed-temporary-error.stderr @@ -1,5 +1,5 @@ error[E0597]: borrowed value does not live long enough - --> $DIR/borrowed-temporary-error.rs:22:10 + --> $DIR/borrowed-temporary-error.rs:20:10 | LL | &(v,) | ^^^^ temporary value does not live long enough diff --git a/src/test/ui/nll/borrowed-universal-error-2.rs b/src/test/ui/nll/borrowed-universal-error-2.rs index da03a9fc39b6..9a59cebfccbe 100644 --- a/src/test/ui/nll/borrowed-universal-error-2.rs +++ b/src/test/ui/nll/borrowed-universal-error-2.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: -Znll-dump-cause - #![feature(nll)] #![allow(warnings)] diff --git a/src/test/ui/nll/borrowed-universal-error-2.stderr b/src/test/ui/nll/borrowed-universal-error-2.stderr index ff999a71e0f9..2e4d7cc8f818 100644 --- a/src/test/ui/nll/borrowed-universal-error-2.stderr +++ b/src/test/ui/nll/borrowed-universal-error-2.stderr @@ -1,5 +1,5 @@ error[E0597]: `v` does not live long enough - --> $DIR/borrowed-universal-error-2.rs:18:5 + --> $DIR/borrowed-universal-error-2.rs:16:5 | LL | &v | ^^ borrowed value does not live long enough @@ -7,8 +7,8 @@ LL | //~^ ERROR `v` does not live long enough [E0597] LL | } | - borrowed value only lives until here | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 16:1... - --> $DIR/borrowed-universal-error-2.rs:16:1 +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:1... + --> $DIR/borrowed-universal-error-2.rs:14:1 | LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/nll/borrowed-universal-error.rs b/src/test/ui/nll/borrowed-universal-error.rs index fdc4c29071ee..9482b9b14000 100644 --- a/src/test/ui/nll/borrowed-universal-error.rs +++ b/src/test/ui/nll/borrowed-universal-error.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: -Znll-dump-cause - #![feature(nll)] #![allow(warnings)] diff --git a/src/test/ui/nll/borrowed-universal-error.stderr b/src/test/ui/nll/borrowed-universal-error.stderr index 4a3d0c6d959f..3e9a3ceb1dba 100644 --- a/src/test/ui/nll/borrowed-universal-error.stderr +++ b/src/test/ui/nll/borrowed-universal-error.stderr @@ -1,5 +1,5 @@ error[E0597]: borrowed value does not live long enough - --> $DIR/borrowed-universal-error.rs:22:12 + --> $DIR/borrowed-universal-error.rs:20:12 | LL | gimme(&(v,)) | ^^^^ temporary value does not live long enough @@ -7,8 +7,8 @@ LL | //~^ ERROR borrowed value does not live long enough [E0597] LL | } | - temporary value only lives until here | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 20:1... - --> $DIR/borrowed-universal-error.rs:20:1 +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 18:1... + --> $DIR/borrowed-universal-error.rs:18:1 | LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/nll/capture-ref-in-struct.rs b/src/test/ui/nll/capture-ref-in-struct.rs index 74b086ab18a5..f49e06bd9e8c 100644 --- a/src/test/ui/nll/capture-ref-in-struct.rs +++ b/src/test/ui/nll/capture-ref-in-struct.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags:-Znll-dump-cause - // Test that a structure which tries to store a pointer to `y` into // `p` (indirectly) fails to compile. diff --git a/src/test/ui/nll/capture-ref-in-struct.stderr b/src/test/ui/nll/capture-ref-in-struct.stderr index 1c545906893a..0fb718075849 100644 --- a/src/test/ui/nll/capture-ref-in-struct.stderr +++ b/src/test/ui/nll/capture-ref-in-struct.stderr @@ -1,5 +1,5 @@ error[E0597]: `y` does not live long enough - --> $DIR/capture-ref-in-struct.rs:33:16 + --> $DIR/capture-ref-in-struct.rs:31:16 | LL | y: &y, | ^^ borrowed value does not live long enough diff --git a/src/test/ui/nll/closure-requirements/escape-argument.rs b/src/test/ui/nll/closure-requirements/escape-argument.rs index 17fadf0a2978..7e918c6431de 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument.rs +++ b/src/test/ui/nll/closure-requirements/escape-argument.rs @@ -22,7 +22,7 @@ // basically checking that the MIR type checker correctly enforces the // closure signature. -// compile-flags:-Znll -Zborrowck=mir -Znll-dump-cause -Zverbose +// compile-flags:-Znll -Zborrowck=mir -Zverbose #![feature(rustc_attrs)] diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-nested.rs b/src/test/ui/nll/closure-requirements/escape-upvar-nested.rs index 984c9fe7c34b..05700ae00ad4 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-nested.rs +++ b/src/test/ui/nll/closure-requirements/escape-upvar-nested.rs @@ -15,7 +15,7 @@ // // except that the closure does so via a second closure. -// compile-flags:-Znll -Zborrowck=mir -Znll-dump-cause -Zverbose +// compile-flags:-Znll -Zborrowck=mir -Zverbose #![feature(rustc_attrs)] diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-ref.rs b/src/test/ui/nll/closure-requirements/escape-upvar-ref.rs index 499ebd659556..93d8bfafcbaa 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-ref.rs +++ b/src/test/ui/nll/closure-requirements/escape-upvar-ref.rs @@ -19,7 +19,7 @@ // `'b`. This relationship is propagated to the closure creator, // which reports an error. -// compile-flags:-Znll -Zborrowck=mir -Znll-dump-cause -Zverbose +// compile-flags:-Znll -Zborrowck=mir -Zverbose #![feature(rustc_attrs)] diff --git a/src/test/ui/nll/drop-no-may-dangle.rs b/src/test/ui/nll/drop-no-may-dangle.rs index 0220858a0d59..3d9a5456cbb3 100644 --- a/src/test/ui/nll/drop-no-may-dangle.rs +++ b/src/test/ui/nll/drop-no-may-dangle.rs @@ -13,7 +13,7 @@ // because of destructor. (Note that the stderr also identifies this // destructor in the error message.) -// compile-flags:-Znll -Zborrowck=mir -Znll-dump-cause +// compile-flags:-Znll -Zborrowck=mir #![allow(warnings)] #![feature(dropck_eyepatch)] diff --git a/src/test/ui/nll/get_default.rs b/src/test/ui/nll/get_default.rs index 7c52a0c87af9..e5944e75e424 100644 --- a/src/test/ui/nll/get_default.rs +++ b/src/test/ui/nll/get_default.rs @@ -13,7 +13,7 @@ // a variety of errors from the older, AST-based machinery (notably // borrowck), and then we get the NLL error at the end. -// compile-flags:-Znll -Zborrowck=compare -Znll-dump-cause +// compile-flags:-Znll -Zborrowck=compare struct Map { } diff --git a/src/test/ui/nll/guarantor-issue-46974.stderr b/src/test/ui/nll/guarantor-issue-46974.stderr index 4bcbb596e5c4..82c5e8dafdce 100644 --- a/src/test/ui/nll/guarantor-issue-46974.stderr +++ b/src/test/ui/nll/guarantor-issue-46974.stderr @@ -6,6 +6,8 @@ LL | let t = &mut *s; // this borrow should last for the entire function LL | let x = &t.0; LL | *s = (2,); //~ ERROR cannot assign to `*s` | ^^^^^^^^^ assignment to borrowed `*s` occurs here +LL | *x + | -- borrow later used here error[E0621]: explicit lifetime required in the type of `s` --> $DIR/guarantor-issue-46974.rs:25:5 diff --git a/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs b/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs index 184dfe320d33..d4df2a01c814 100644 --- a/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs +++ b/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//compile-flags: -Z emit-end-regions -Zborrowck=mir -Z nll -Znll-dump-cause +//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll #![allow(warnings)] diff --git a/src/test/ui/nll/maybe-initialized-drop-with-fragment.rs b/src/test/ui/nll/maybe-initialized-drop-with-fragment.rs index beb2c87f8f3b..2eb90dca7026 100644 --- a/src/test/ui/nll/maybe-initialized-drop-with-fragment.rs +++ b/src/test/ui/nll/maybe-initialized-drop-with-fragment.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll -Znll-dump-cause +//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll #![allow(warnings)] diff --git a/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs b/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs index 39cad8acee18..f639d8f243f1 100644 --- a/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs +++ b/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll -Znll-dump-cause +//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll #![allow(warnings)] diff --git a/src/test/ui/nll/maybe-initialized-drop.rs b/src/test/ui/nll/maybe-initialized-drop.rs index 767c5b9b8be8..c2cc479d28e3 100644 --- a/src/test/ui/nll/maybe-initialized-drop.rs +++ b/src/test/ui/nll/maybe-initialized-drop.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll -Znll-dump-cause +//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll #![allow(warnings)] diff --git a/src/test/ui/nll/return-ref-mut-issue-46557.stderr b/src/test/ui/nll/return-ref-mut-issue-46557.stderr index c77e0772ce96..2184beac99b6 100644 --- a/src/test/ui/nll/return-ref-mut-issue-46557.stderr +++ b/src/test/ui/nll/return-ref-mut-issue-46557.stderr @@ -1,11 +1,16 @@ error[E0597]: borrowed value does not live long enough --> $DIR/return-ref-mut-issue-46557.rs:17:21 | -LL | let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597] - | ^^^^^^^ temporary value does not live long enough -LL | x -LL | } - | - temporary value only lives until here +LL | fn gimme_static_mut() -> &'static mut u32 { + | ___________________________________________- +LL | | let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597] + | | ^^^^^^^ temporary value does not live long enough +LL | | x +LL | | } + | | - + | | | + | |_temporary value only lives until here + | borrow later used here error: aborting due to previous error