]> git.lizzy.rs Git - rust.git/commitdiff
Remove nll-dump-cause flag and always track causes
authorSantiago Pastorino <spastorino@gmail.com>
Mon, 5 Mar 2018 22:29:05 +0000 (19:29 -0300)
committerSantiago Pastorino <spastorino@gmail.com>
Tue, 6 Mar 2018 13:34:46 +0000 (10:34 -0300)
28 files changed:
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/values.rs
src/test/ui/issue-45157.stderr
src/test/ui/nll/borrowed-local-error.rs
src/test/ui/nll/borrowed-local-error.stderr
src/test/ui/nll/borrowed-match-issue-45045.stderr
src/test/ui/nll/borrowed-referent-issue-38899.stderr
src/test/ui/nll/borrowed-temporary-error.rs
src/test/ui/nll/borrowed-temporary-error.stderr
src/test/ui/nll/borrowed-universal-error-2.rs
src/test/ui/nll/borrowed-universal-error-2.stderr
src/test/ui/nll/borrowed-universal-error.rs
src/test/ui/nll/borrowed-universal-error.stderr
src/test/ui/nll/capture-ref-in-struct.rs
src/test/ui/nll/capture-ref-in-struct.stderr
src/test/ui/nll/closure-requirements/escape-argument.rs
src/test/ui/nll/closure-requirements/escape-upvar-nested.rs
src/test/ui/nll/closure-requirements/escape-upvar-ref.rs
src/test/ui/nll/drop-no-may-dangle.rs
src/test/ui/nll/get_default.rs
src/test/ui/nll/guarantor-issue-46974.stderr
src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.rs
src/test/ui/nll/maybe-initialized-drop-with-fragment.rs
src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.rs
src/test/ui/nll/maybe-initialized-drop.rs
src/test/ui/nll/return-ref-mut-issue-46557.stderr

index 157614f847a1242cea3386ceea96d6dd08bf815f..194b014c97b21a4e94d0fed250d78d4a108caabb 100644 (file)
@@ -1312,8 +1312,6 @@ fn parse_epoch(slot: &mut Epoch, v: Option<&str>) -> bool {
         "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<bool> = (None, parse_opt_bool, [TRACKED],
index 5e9eeb973007f26f71fc0c366d1d4cdad6e6a1e8..067e480bd60ede6a7e9615bed07e671a1167a1c3 100644 (file)
@@ -476,13 +476,6 @@ pub fn init_features(&self, features: feature_gate::Features) {
         *(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
index 3ffb4370359bf81dad95334ea71787d363940854..2151592fd663b45474a3337ca2dfeeeb466dd742 100644 (file)
@@ -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 @@ pub(crate) fn new(
             .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(),
index e6f2a43bfc8f79d74ec021fc051b935836c7aa29..74ee04e0fb15e79f977c05104e8f070df7bd9e94 100644 (file)
@@ -17,7 +17,7 @@
 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<RegionValueElements>,
         num_region_variables: usize,
-        track_causes: TrackCauses,
     ) -> Self {
         assert!(
             elements.num_universal_regions <= num_region_variables,
@@ -215,11 +214,7 @@ pub(super) fn new(
                 RegionVid::new(num_region_variables),
                 RegionElementIndex::new(elements.num_elements()),
             ),
-            causes: if track_causes.0 {
-                Some(CauseMap::default())
-            } else {
-                None
-            },
+            causes: Some(CauseMap::default()),
         }
     }
 
index 3ce93da6ad5500cee7015f09f42b3ec26c575f8e..bec91f7f70dee9d86e5568302f49656e8e054451 100644 (file)
@@ -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
 
index 785a38da95980362949f8860eb3bed590f91214e..084d0c159ef3953ec99664a0ec515bbe95c0c4a1 100644 (file)
@@ -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 {
index 3bc1978554821af639a2e80917c29d6ab8587d94..24964f651f79d47e51d352d309e3cc3e7557d890 100644 (file)
@@ -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({
    |  _____________-
index 144eba8cb76955c5303e21a86c615762d0238ee1..a80bc686e34aa80a8668164e479a04b007e8d121 100644 (file)
@@ -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
 
index 91f81783297515b998a548ef91e46f2334cd58bb..675f85ecb4dd2ed78741d6ec92e96e94eb61fab3 100644 (file)
@@ -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
 
index e1a6112d173f9d469a03cadf9097bd158d3078bb..7aad7205a52a192876ab4ab809d00aa6e8cd30c4 100644 (file)
@@ -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 {
index f5cb1dccc378639f066fd67c3b98d0c6bc86ba76..575d9b5a62d7135f4a70af18c27f97c7d9ce4715 100644 (file)
@@ -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
index da03a9fc39b632adb7d07e95e58801f4a94ea18e..9a59cebfccbe2089e47ce430f22ed9fe26f8326f 100644 (file)
@@ -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)]
 
index ff999a71e0f92e603e420ba8b699cd436dff117a..2e4d7cc8f818d02ec6c53570b0e3c6f05ab4711a 100644 (file)
@@ -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 {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index fdc4c29071ee9500ca523b5d679365ac06a65adc..9482b9b140002543fc9bd812d0271a4f223f2b30 100644 (file)
@@ -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)]
 
index 4a3d0c6d959fce2de0ac19212c74cb577614b09d..3e9a3ceb1dba41bf7db1e38c02d587360defd225 100644 (file)
@@ -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 {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index 74b086ab18a585415808241b16b8d3d9ab2dc4a5..f49e06bd9e8c8c340228af0a2799d5c8c27f5445 100644 (file)
@@ -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.
 
index 1c545906893a232c24436ae134940cc5806c7c71..0fb718075849c4d8c419fb1f998431bde3e527ec 100644 (file)
@@ -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
index 17fadf0a2978b4f235cb5ab0264de530e1183400..7e918c6431de4450e874558b91bee2001218119e 100644 (file)
@@ -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)]
 
index 984c9fe7c34bd3b92a9c28d852364503b5fc325e..05700ae00ad4f72900ad96f2cdec06474a528f22 100644 (file)
@@ -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)]
 
index 499ebd659556ce57663b3b9322e984ac563bca44..93d8bfafcbaa4ffed82d2b0be51f828a7d2b679b 100644 (file)
@@ -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)]
 
index 0220858a0d59ed265eb0a5d2fda03953559ca8c0..3d9a5456cbb3666972e79e19cbda3513f513b9ec 100644 (file)
@@ -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)]
index 7c52a0c87af95d269ebc0b6e4aa8e8a1b75070c0..e5944e75e424177fad5749b7c110b00e7930d19b 100644 (file)
@@ -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 {
 }
index 4bcbb596e5c4b4e3451c014770b663ac1dddd042..82c5e8dafdcedf5488e6dcadf2d2e93c88120b20 100644 (file)
@@ -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
index 184dfe320d33d7caedd0da90165d726d1bbdef71..d4df2a01c8143e97a6c4a30df74c8d30be74e158 100644 (file)
@@ -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)]
index beb2c87f8f3bd4e6cea9be0f1b810442572a8d1a..2eb90dca7026ec2182d728b9d2c6e8ed7c2f0970 100644 (file)
@@ -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)]
 
index 39cad8acee18117f190fc36732b53527d93ff535..f639d8f243f1423cfeb124a4bdd3267cd6f49b50 100644 (file)
@@ -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)]
 
index 767c5b9b8be8dd1deb1f29d8230a313d735e0ebd..c2cc479d28e3e78a12a69a2c098ad34449d71378 100644 (file)
@@ -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)]
 
index c77e0772ce962bc12653dbe4be16f93b084d83ba..2184beac99b668885b01bafff270c2b08bde8807 100644 (file)
@@ -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