about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>2017-09-11 20:27:26 +0530
committerNiko Matsakis <niko@alum.mit.edu>2017-09-26 11:55:52 -0400
commitaa6f0c80507230d864f7af5fe3c4085e28cabfe9 (patch)
treed18b3007124d55e8657f3d1404d27eb0a5e7b234
parente58f528bb0664c33355ff6b0aa125b8a751fee2a (diff)
downloadrust-aa6f0c80507230d864f7af5fe3c4085e28cabfe9.tar.gz
rust-aa6f0c80507230d864f7af5fe3c4085e28cabfe9.zip
modify message for return time having multiple lifetimes
-rw-r--r--src/librustc/infer/error_reporting/different_lifetimes.rs12
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr29
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr9
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr9
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr6
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr4
6 files changed, 27 insertions, 42 deletions
diff --git a/src/librustc/infer/error_reporting/different_lifetimes.rs b/src/librustc/infer/error_reporting/different_lifetimes.rs
index 687b518ef6a..e9866545f97 100644
--- a/src/librustc/infer/error_reporting/different_lifetimes.rs
+++ b/src/librustc/infer/error_reporting/different_lifetimes.rs
@@ -82,7 +82,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
             self.is_return_type_anon(scope_def_id_sub, bregion_sub, ty_fndecl_sub);
 
         let span_label_var1 = if let Some(simple_name) = anon_arg_sup.pat.simple_name() {
-            format!(" flows from `{}`", simple_name)
+            format!(" from `{}`", simple_name)
         } else {
             format!("")
         };
@@ -103,21 +103,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
                              format!(" with one lifetime"),
                              format!(" into the other")))
                 } else {
-                    (format!("these two types was declared with multiple lifetimes..."),
+                    (format!("these two types was declared with different lifetimes..."),
                      format!("...but data{} flows{} here",
                              span_label_var1,
                              span_label_var2))
                 };
                 (ty_sup.span, ty_sub.span, main_label_1, span_label_1)
             }
-            (Some(ret_span1), Some(ret_span2)) => {
-                (ret_span1,
-                 ret_span2,
-                 format!("the return type is declared with different lifetimes..."),
-                 format!("...but data{} flows{} here",
-                         format!(" with one lifetime"),
-                         format!(" into the other")))
-            }
             
             (Some(ret_span), _) => {
                 (ty_sub.span,
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr
index 9e4f6c42179..f383a4dcf67 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr
@@ -1,27 +1,14 @@
-error[E0312]: lifetime of reference outlives lifetime of borrowed content...
+error[E0623]: lifetime mismatch
   --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:21:20
    |
+19 |     fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
+   |                   ----                 -------
+   |                   |
+   |                   this parameter and the return type are declared
+                  with different lifetimes...
+20 | 
 21 |         if x > y { x } else { y }
-   |                    ^
-   |
-note: ...the reference is valid for the lifetime 'a as defined on the method body at 19:5...
-  --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:19:5
-   |
-19 | /     fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
-20 | |
-21 | |         if x > y { x } else { y }
-22 | |
-23 | |     }
-   | |_____^
-note: ...but the borrowed content is only valid for the anonymous lifetime #1 defined on the method body at 19:5
-  --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:19:5
-   |
-19 | /     fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
-20 | |
-21 | |         if x > y { x } else { y }
-22 | |
-23 | |     }
-   | |_____^
+   |                    ^ ...but data flows `x` is returned here
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr
index 4a1673a531d..27a674e5bb7 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr
@@ -1,11 +1,14 @@
-error[E0621]: explicit lifetime required in the type of `self`
+error[E0623]: lifetime mismatch
   --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:18:5
    |
 16 |   fn foo<'a>(&self, x: &'a i32) -> &i32 {
-   |              ----- consider changing the type of `self` to `&'a Foo`
+   |                        -------     ----
+   |                        |
+   |                        this parameter and the return type are declared
+                  with different lifetimes...
 17 | 
 18 |     x
-   |     ^ lifetime `'a` required
+   |     ^ ...but data flows from `x` is returned here
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr
index 973c5ed72f8..8f957d1b009 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr
@@ -1,11 +1,14 @@
-error[E0621]: explicit lifetime required in the type of `self`
+error[E0623]: lifetime mismatch
   --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:18:30
    |
 16 |     fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
-   |                ----- consider changing the type of `self` to `&'a Foo`
+   |                -----                 -------
+   |                |
+   |                this parameter and the return type are declared
+                  with different lifetimes...
 17 | 
 18 |         if true { x } else { self }
-   |                              ^^^^ lifetime `'a` required
+   |                              ^^^^ ...but data flows from `self` is returned here
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr
index c6b1280ca95..1ea2a4ff8ad 100644
--- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr
@@ -1,11 +1,11 @@
-error[E0621]: explicit lifetime required in the type of `self`
+error[E0623]: lifetime mismatch
   --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:17:5
    |
 16 |   fn foo<'a>(&self, x: &i32) -> &i32 {
    |                        ----     ----
    |                        |
-   |                        this parameter and the return type are
-                            declared with different lifetimes...
+   |                        this parameter and the return type are declared
+                  with different lifetimes...
 17 |     x
    |     ^ ...but data from `x` is returned here
 
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr
index 9b15de1b173..316b76c6460 100644
--- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr
@@ -4,8 +4,8 @@ error[E0623]: lifetime mismatch
 16 |     fn foo<'a>(&self, x: &Foo) -> &Foo {
    |                          ----     ----
    |                          |
-   |                          this parameter and the return type are
-                            declared with different lifetimes...
+   |                          this parameter and the return type are declared
+                  with different lifetimes...
 17 |         if true { x } else { self }
    |                   ^ ...but data from `x` is returned here