about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorMark Simulacrum <mark.simulacrum@gmail.com>2017-09-29 17:58:51 -0600
committerGitHub <noreply@github.com>2017-09-29 17:58:51 -0600
commitf407b2bf4aa8154cd398c7823474efee8be17213 (patch)
treee363a7b8f2a255bb7d8645ca94c461917fcc84c7 /src/test/ui
parent6f87d20a7cce70b8cc59a1adf3037d14bc83f237 (diff)
parent73543d53cd01899df38ce71b883ed820c5822fba (diff)
Rollup merge of #44124 - gaurikholkar:return_self, r=arielb1
adding E0623 for return types - both parameters are anonymous

This is a fix for #44018
```
error[E0621]: explicit lifetime required in the type of `self`
  --> $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...
17 |     x
   |     ^ ...but data from `x` is returned here

error: aborting due to previous error
```
It also works for the below case where we have self as anonymous

```
error[E0623]: lifetime mismatch
  --> src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs:17:19
   |
16 |     fn foo<'a>(&self, x: &Foo) -> &Foo {
   |                          ----     ----
   |                          |
   |                          this parameter and the return type are
                            declared with different lifetimes...
17 |         if true { x } else { self }
   |                   ^ ...but data from `x` is returned here

error: aborting due to previous error
```
r? @nikomatsakis

Currently, I have enabled E0621 where return type and self are anonymous, hence WIP.
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr28
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr28
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr28
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr23
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr23
7 files changed, 35 insertions, 99 deletions
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..cb9a1edf1dd 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,13 @@
-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 from `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 e3fd0192053..8af6acc62c4 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,27 +1,13 @@
-error[E0312]: lifetime of reference outlives lifetime of borrowed content...
+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 {
+   |                        -------     ----
+   |                        |
+   |                        this parameter and the return type are declared with different lifetimes...
+17 | 
 18 |     x
-   |     ^
-   |
-note: ...the reference is valid for the anonymous lifetime #1 defined on the method body at 16:3...
-  --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:16:3
-   |
-16 | /   fn foo<'a>(&self, x: &'a i32) -> &i32 {
-17 | |
-18 | |     x
-19 | |
-20 | |   }
-   | |___^
-note: ...but the borrowed content is only valid for the lifetime 'a as defined on the method body at 16:3
-  --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:16:3
-   |
-16 | /   fn foo<'a>(&self, x: &'a i32) -> &i32 {
-17 | |
-18 | |     x
-19 | |
-20 | |   }
-   | |___^
+   |     ^ ...but data 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 8551f015db5..c09de0c33af 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,27 +1,13 @@
-error[E0312]: lifetime of reference outlives lifetime of borrowed content...
+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 {
+   |                -----                 -------
+   |                |
+   |                this parameter and the return type are declared with different lifetimes...
+17 | 
 18 |         if true { x } else { self }
-   |                              ^^^^
-   |
-note: ...the reference is valid for the lifetime 'a as defined on the method body at 16:5...
-  --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:16:5
-   |
-16 | /     fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
-17 | |
-18 | |         if true { x } else { self }
-19 | |
-20 | |     }
-   | |_____^
-note: ...but the borrowed content is only valid for the anonymous lifetime #1 defined on the method body at 16:5
-  --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:16:5
-   |
-16 | /     fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
-17 | |
-18 | |         if true { x } else { self }
-19 | |
-20 | |     }
-   | |_____^
+   |                              ^^^^ ...but data from `self` is returned here
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr
index 1b5ac7c7b57..73460277de4 100644
--- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr
@@ -4,7 +4,7 @@ error[E0623]: lifetime mismatch
 15 | fn foo(mut x: Ref) {
    |               ---
    |               |
-   |               this type was declared with multiple lifetimes...
+   |               this type is declared with multiple lifetimes...
 16 |     x.a = x.b;
    |           ^^^ ...but data with one lifetime flows into the other here
 
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr
index 689a1ac292b..fb524ae62c5 100644
--- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr
@@ -4,7 +4,7 @@ error[E0623]: lifetime mismatch
 15 | fn foo(mut x: Ref) {
    |               ---
    |               |
-   |               this type was declared with multiple lifetimes...
+   |               this type is declared with multiple lifetimes...
 16 |     x.a = x.b;
    |           ^^^ ...but data with one lifetime flows into the other here
 
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 890f9b311e7..1409b216133 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,23 +1,12 @@
-error[E0312]: lifetime of reference outlives lifetime of borrowed content...
+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...
 17 |     x
-   |     ^
-   |
-note: ...the reference is valid for the anonymous lifetime #1 defined on the method body at 16:3...
-  --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:16:3
-   |
-16 | /   fn foo<'a>(&self, x: &i32) -> &i32 {
-17 | |     x
-18 | |   }
-   | |___^
-note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined on the method body at 16:3
-  --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:16:3
-   |
-16 | /   fn foo<'a>(&self, x: &i32) -> &i32 {
-17 | |     x
-18 | |   }
-   | |___^
+   |     ^ ...but data from `x` is returned here
 
 error: aborting due to previous error
 
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 43f00c32c62..cae45023e26 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
@@ -1,23 +1,12 @@
-error[E0312]: lifetime of reference outlives lifetime of borrowed content...
+error[E0623]: lifetime mismatch
   --> $DIR/ex3-both-anon-regions-self-is-anon.rs:17:19
    |
+16 |     fn foo<'a>(&self, x: &Foo) -> &Foo {
+   |                          ----     ----
+   |                          |
+   |                          this parameter and the return type are declared with different lifetimes...
 17 |         if true { x } else { self }
-   |                   ^
-   |
-note: ...the reference is valid for the anonymous lifetime #1 defined on the method body at 16:5...
-  --> $DIR/ex3-both-anon-regions-self-is-anon.rs:16:5
-   |
-16 | /     fn foo<'a>(&self, x: &Foo) -> &Foo {
-17 | |         if true { x } else { self }
-18 | |     }
-   | |_____^
-note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined on the method body at 16:5
-  --> $DIR/ex3-both-anon-regions-self-is-anon.rs:16:5
-   |
-16 | /     fn foo<'a>(&self, x: &Foo) -> &Foo {
-17 | |         if true { x } else { self }
-18 | |     }
-   | |_____^
+   |                   ^ ...but data from `x` is returned here
 
 error: aborting due to previous error