]> git.lizzy.rs Git - rust.git/commitdiff
remove unnecessary `blame_span` from `report_region_errors`
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 23 Jul 2018 16:46:42 +0000 (19:46 +0300)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 25 Jul 2018 03:38:20 +0000 (06:38 +0300)
22 files changed:
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
src/test/ui/issue-40288-2.nll.stderr
src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.nll.stderr
src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr
src/test/ui/lifetime-errors/ex2a-push-one-existing-name.nll.stderr
src/test/ui/lifetime-errors/ex2b-push-no-existing-names.nll.stderr
src/test/ui/lifetime-errors/ex2c-push-inference-variable.nll.stderr
src/test/ui/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr
src/test/ui/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions-2.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions-3.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr
src/test/ui/lifetime-errors/ex3-both-anon-regions.nll.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr

index 131e1defc1f9e47fd35bca7591e99b1062b82259..87c58bf8ae7ee2b4e8d9a1b43d6929b43df827ba 100644 (file)
@@ -199,19 +199,10 @@ pub(super) fn report_error(
         mir_def_id: DefId,
         fr: RegionVid,
         outlived_fr: RegionVid,
-        blame_span: Span,
         errors_buffer: &mut Vec<Diagnostic>,
     ) {
         debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
 
-        if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
-            let tables = infcx.tcx.typeck_tables_of(mir_def_id);
-            let nice = NiceRegionError::new_from_span(infcx.tcx, blame_span, o, f, Some(tables));
-            if let Some(_error_reported) = nice.try_report() {
-                return;
-            }
-        }
-
         // Find all paths
         let constraint_paths = self.find_constraint_paths_between_regions(fr, |r| r == outlived_fr);
         debug!("report_error: constraint_paths={:#?}", constraint_paths);
@@ -233,6 +224,15 @@ pub(super) fn report_error(
         // Get a span
         let (category, span) = categorized_path.first().unwrap();
 
+        // Check if we can use one of the "nice region errors".
+        if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
+            let tables = infcx.tcx.typeck_tables_of(mir_def_id);
+            let nice = NiceRegionError::new_from_span(infcx.tcx, *span, o, f, Some(tables));
+            if let Some(_error_reported) = nice.try_report() {
+                return;
+            }
+        }
+
         let category = match (
             category,
             self.universal_regions.is_local_free_region(fr),
index 3ba95895bfdaf7c672001fa31f780fd9ba07a33d..ea1e8b346bd42b8dd88e9c1a645dee992c0495d2 100644 (file)
@@ -921,7 +921,7 @@ fn check_universal_region<'gcx>(
             // to report the error. This gives better error messages
             // in some cases.
             self.report_error(
-                mir, infcx, mir_def_id, longer_fr, shorter_fr, blame_span, errors_buffer);
+                mir, infcx, mir_def_id, longer_fr, shorter_fr, errors_buffer);
         }
     }
 }
index fcff5c6a8edadb0379875984ee6652b544b0ea5f..319e7ef38601d7fdc4a39047845ffb4b84a7f9ac 100644 (file)
@@ -35,20 +35,22 @@ LL |     let mut out = Struct { head: x, _tail: [()] };
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0621]: explicit lifetime required in the type of `y`
-  --> $DIR/issue-40288-2.rs:14:9
+  --> $DIR/issue-40288-2.rs:16:31
    |
 LL | fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
    |                                                      - consider changing the type of `y` to `&'a T`
-LL |     let mut out = [x];
-   |         ^^^^^^^ lifetime `'a` required
+...
+LL |         let slice: &mut [_] = &mut out;
+   |                               ^^^^^^^^ lifetime `'a` required
 
 error[E0621]: explicit lifetime required in the type of `y`
-  --> $DIR/issue-40288-2.rs:29:9
+  --> $DIR/issue-40288-2.rs:31:41
    |
 LL | fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
    |                                                       - consider changing the type of `y` to `&'a T`
-LL |     let mut out = Struct { head: x, _tail: [()] };
-   |         ^^^^^^^ lifetime `'a` required
+...
+LL |         let dst: &mut Struct<_, [()]> = &mut out;
+   |                                         ^^^^^^^^ lifetime `'a` required
 
 error: aborting due to 2 previous errors
 
index 1e45914138de544ce03ea8678c4d16a005beec8f..4d9517eca6032dfa5acd28382faae51a2620ba70 100644 (file)
@@ -5,12 +5,12 @@ LL |     if x > y { x } else { y } //~ ERROR explicit lifetime
    |                           ^
 
 error[E0621]: explicit lifetime required in parameter type
-  --> $DIR/ex1-return-one-existing-name-if-else-3.rs:11:13
+  --> $DIR/ex1-return-one-existing-name-if-else-3.rs:11:16
    |
 LL | fn foo<'a>((x, y): (&'a i32, &i32)) -> &'a i32 {
-   |            -^----
-   |            ||
-   |            |lifetime `'a` required
+   |            ----^-
+   |            |   |
+   |            |   lifetime `'a` required
    |            consider changing type to `(&'a i32, &'a i32)`
 
 error: aborting due to previous error
index a51d9307d074d0bae99eea66e0dee9d2ee5e4dc4..087c9eb389b55bad57f2fc2e9893a80886fd8c69 100644 (file)
@@ -10,7 +10,7 @@ error[E0621]: explicit lifetime required in the type of `x`
 LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
    |            - consider changing the type of `x` to `Ref<'a, i32>`
 LL |     y.push(x); //~ ERROR explicit lifetime
-   |     ^ lifetime `'a` required
+   |     ^^^^^^^^^ lifetime `'a` required
 
 error: aborting due to previous error
 
index e50fd74faf4badfaf240a207689c607a9d693012..80192af221755b8ca2ca6f07aedc7741c4c9d6c9 100644 (file)
@@ -10,7 +10,7 @@ error[E0621]: explicit lifetime required in the type of `y`
 LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
    |                                       - consider changing the type of `y` to `Ref<'a, i32>`
 LL |     x.push(y); //~ ERROR explicit lifetime
-   |     ^ lifetime `'a` required
+   |     ^^^^^^^^^ lifetime `'a` required
 
 error: aborting due to previous error
 
index 283192c6843927cb19dd1f26563d62cf03836540..4b4fdde940f7e26f1d226a7380407dd3fe1635a2 100644 (file)
@@ -10,7 +10,7 @@ error[E0623]: lifetime mismatch
 LL | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
    |                    --------      -------- these two types are declared with different lifetimes...
 LL |     x.push(y); //~ ERROR lifetime mismatch
-   |     ^ ...but data from `y` flows into `x` here
+   |     ^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index 2ca202b402cee0f666dbdb87fef7631b0bb2b1f5..f55fd291249c6aa9921ee4e390b7676ce16a7b22 100644 (file)
@@ -5,12 +5,13 @@ LL |     let z = Ref { data: y.data };
    |             ^^^
 
 error[E0623]: lifetime mismatch
-  --> $DIR/ex2c-push-inference-variable.rs:16:9
+  --> $DIR/ex2c-push-inference-variable.rs:17:5
    |
 LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
    |                                   ------------      ------------ these two types are declared with different lifetimes...
 LL |     let z = Ref { data: y.data };
-   |         ^ ...but data from `y` flows into `x` here
+LL |     x.push(z); //~ ERROR lifetime mismatch
+   |     ^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index 712c25f8929d4fcb5a43ecbcf76ef2c2adabed3d..85b5f3e890008554a9d802d335c61cf478ba8d44 100644 (file)
@@ -5,12 +5,13 @@ LL |     let b = Ref { data: y.data };
    |             ^^^
 
 error[E0623]: lifetime mismatch
-  --> $DIR/ex2d-push-inference-variable-2.rs:16:9
+  --> $DIR/ex2d-push-inference-variable-2.rs:18:5
    |
 LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
    |                                   ------------      ------------ these two types are declared with different lifetimes...
-LL |     let a: &mut Vec<Ref<i32>> = x; //~ ERROR lifetime mismatch
-   |         ^ ...but data from `y` flows into `x` here
+...
+LL |     a.push(b);
+   |     ^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index 351966902a4fba657ef3ab0a48569e12f1d0810a..7e5182a5d30c940b2f2363d950dafec273167d92 100644 (file)
@@ -5,12 +5,13 @@ LL |     let b = Ref { data: y.data };
    |             ^^^
 
 error[E0623]: lifetime mismatch
-  --> $DIR/ex2e-push-inference-variable-3.rs:16:9
+  --> $DIR/ex2e-push-inference-variable-3.rs:18:5
    |
 LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
    |                                   ------------      ------------ these two types are declared with different lifetimes...
-LL |     let a: &mut Vec<Ref<i32>> = x; //~ ERROR lifetime mismatch
-   |         ^ ...but data from `y` flows into `x` here
+...
+LL |     Vec::push(a, b);
+   |     ^^^^^^^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index da171577e2d8b33f6d30c13e4698826742e03a1e..36317c4570b982fe73a104fc6fcfb02d2d1f15bd 100644 (file)
@@ -5,12 +5,12 @@ LL |     *v = x; //~ ERROR lifetime mismatch
    |          ^
 
 error[E0623]: lifetime mismatch
-  --> $DIR/ex3-both-anon-regions-2.rs:11:14
+  --> $DIR/ex3-both-anon-regions-2.rs:12:5
    |
 LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
-   |              ^^^^^^^^^            ---           --- these two types are declared with different lifetimes...
-   |              |
-   |              ...but data from `x` flows here
+   |                                   ---           --- these two types are declared with different lifetimes...
+LL |     *v = x; //~ ERROR lifetime mismatch
+   |     ^^^^^^ ...but data from `x` flows here
 
 error: aborting due to previous error
 
index 102981977e55756eaa324db92bd8a572402a002c..61af34747ca9bb0b429f7b20cb45abde8be684b8 100644 (file)
@@ -19,12 +19,12 @@ LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
    |                                 ...but data flows into `z` here
 
 error[E0623]: lifetime mismatch
-  --> $DIR/ex3-both-anon-regions-3.rs:11:33
+  --> $DIR/ex3-both-anon-regions-3.rs:11:36
    |
 LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
-   |                         ---     ^            --- these two types are declared with different lifetimes...
-   |                                 |
-   |                                 ...but data flows into `z` here
+   |                         ---        ^         --- these two types are declared with different lifetimes...
+   |                                    |
+   |                                    ...but data flows into `z` here
 
 error: aborting due to 2 previous errors
 
index 9d1f6a3e36f1b53d40a2faa099ee164273c1a84e..2a5729952e33d3e691dd50017c730bb4bb3a9997 100644 (file)
@@ -11,7 +11,7 @@ LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>)
    |                           -------      ------- these two types are declared with different lifetimes...
 ...
 LL |     x.push(y); //~ ERROR lifetime mismatch
-   |     ^ ...but data from `y` flows into `x` here
+   |     ^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index 5df93fd5547c7d306311893b81e38b927a757948..6efc8d3da06776ad6cd66b96c24d1e98b6d1e066 100644 (file)
@@ -10,7 +10,7 @@ error[E0623]: lifetime mismatch
 LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) {
    |                           -------      ------- these two types are declared with different lifetimes...
 LL |     x.push(y); //~ ERROR lifetime mismatch
-   |     ^ ...but data from `y` flows into `x` here
+   |     ^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index cd602cf950b18e3c76419e729225459e513eb360..0f555020822cb42f4559e21eedc3de6336237aee 100644 (file)
@@ -10,7 +10,7 @@ error[E0623]: lifetime mismatch
 LL | fn foo(mut x: Vec<Ref>, y: Ref) {
    |                   ---      --- these two types are declared with different lifetimes...
 LL |     x.push(y); //~ ERROR lifetime mismatch
-   |     ^ ...but data from `y` flows into `x` here
+   |     ^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index 52c90839c32af5d246964702923eabaf7a3a4481..4400644e7fb65299d62adba5139f1cbb574021ad 100644 (file)
@@ -10,7 +10,7 @@ error[E0623]: lifetime mismatch
 LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
    |                           ------      ------ these two types are declared with different lifetimes...
 LL |     x.push(y); //~ ERROR lifetime mismatch
-   |     ^ ...but data from `y` flows into `x` here
+   |     ^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index d5bba6649a2c714bb0cf37bccf24621bb4fa05ff..a0aa1e28d9bc03183b388e96df22287287417686 100644 (file)
@@ -10,7 +10,7 @@ error[E0623]: lifetime mismatch
 LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
    |                               ---      --- these two types are declared with different lifetimes...
 LL |   y.push(z); //~ ERROR lifetime mismatch
-   |   ^ ...but data from `z` flows into `y` here
+   |   ^^^^^^^^^ ...but data from `z` flows into `y` here
 
 error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
   --> $DIR/ex3-both-anon-regions-using-fn-items.rs:11:3
index 4d54f6fe0375c75645f5438772219ea878854219..5d4492701beb33209beab494a81da78dd657c043 100644 (file)
@@ -10,7 +10,7 @@ error[E0623]: lifetime mismatch
 LL |     fn foo(x: &mut Vec<&u8>, y: &u8) {
    |                        ---      --- these two types are declared with different lifetimes...
 LL |         x.push(y); //~ ERROR lifetime mismatch
-   |         ^ ...but data from `y` flows into `x` here
+   |         ^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index 0608b3be8b33aea599e5bc91c6ab8cebf63705b7..37b79cee72f75bec1baf25a23ad67c05cb4542c1 100644 (file)
@@ -10,7 +10,7 @@ error[E0623]: lifetime mismatch
 LL | fn foo(x:Box<Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
    |                 ---  --- these two types are declared with different lifetimes...
 LL |   y.push(z); //~ ERROR lifetime mismatch
-   |   ^ ...but data from `z` flows into `y` here
+   |   ^^^^^^^^^ ...but data from `z` flows into `y` here
 
 error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
   --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:11:3
index c25eedc770d486942e1d4ca131f32a88388a12d8..c11d81a4c13daf9336e2cd9e861c7b4b9bc52eed 100644 (file)
@@ -10,7 +10,7 @@ error[E0623]: lifetime mismatch
 LL | fn foo(x: &mut Vec<&u8>, y: &u8) {
    |                    ---      --- these two types are declared with different lifetimes...
 LL |     x.push(y); //~ ERROR lifetime mismatch
-   |     ^ ...but data from `y` flows into `x` here
+   |     ^^^^^^^^^ ...but data from `y` flows into `x` here
 
 error: aborting due to previous error
 
index 840b4071a8776e172ef175e4d07bc22ad273d734..d713a37fa9f41e8e5a256af006adcae0c490442f 100644 (file)
@@ -24,14 +24,19 @@ LL | |     });
    = note: where '_#1r: '_#2r
 
 error[E0623]: lifetime mismatch
-  --> $DIR/propagate-approximated-ref.rs:53:29
+  --> $DIR/propagate-approximated-ref.rs:53:5
    |
-LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
-   |                                -------                -------
-   |                                |
-   |                                these two types are declared with different lifetimes...
-LL |     establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
-   |                             ^^^^^^^ ...but data from `cell_a` flows into `cell_b` here
+LL |   fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
+   |                                  -------                -------
+   |                                  |
+   |                                  these two types are declared with different lifetimes...
+LL | /     establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
+LL | |         //~^ ERROR lifetime mismatch
+LL | |
+LL | |         // Only works if 'x: 'y:
+LL | |         demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
+LL | |     });
+   | |______^ ...but data from `cell_a` flows into `cell_b` here
 
 note: No external requirements
   --> $DIR/propagate-approximated-ref.rs:52:1
index cf5f4d415b669cc88ddec9555edd86ef80b30c75..f6ad6e46c6299c82b7b38bf30f862916fb2283ca 100644 (file)
@@ -24,14 +24,19 @@ LL | |     });
    = note: where '_#1r: '_#2r
 
 error[E0623]: lifetime mismatch
-  --> $DIR/propagate-approximated-val.rs:46:29
+  --> $DIR/propagate-approximated-val.rs:46:5
    |
-LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
-   |                              -------                -------
-   |                              |
-   |                              these two types are declared with different lifetimes...
-LL |     establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
-   |                             ^^^^^^ ...but data from `cell_a` flows into `cell_b` here
+LL |   fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
+   |                                -------                -------
+   |                                |
+   |                                these two types are declared with different lifetimes...
+LL | /     establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
+LL | |         //~^ ERROR lifetime mismatch
+LL | |
+LL | |         // Only works if 'x: 'y:
+LL | |         demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to nll
+LL | |     });
+   | |______^ ...but data from `cell_a` flows into `cell_b` here
 
 note: No external requirements
   --> $DIR/propagate-approximated-val.rs:45:1