about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>2017-06-26 11:26:01 -0700
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>2017-06-29 06:37:18 -0700
commitaebc4e007493c623aaf69ef04d1a649b74fd5bfb (patch)
treeb89a8b127156d1ff87cdc583b201075da6a9b1e8 /src
parent82f25b32ae568986de275d87fe355ec63307d8cb (diff)
downloadrust-aebc4e007493c623aaf69ef04d1a649b74fd5bfb.tar.gz
rust-aebc4e007493c623aaf69ef04d1a649b74fd5bfb.zip
Changing the error code to E0621
Diffstat (limited to 'src')
-rw-r--r--src/librustc/diagnostics.rs31
-rw-r--r--src/librustc/infer/error_reporting/named_anon_conflict.rs6
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr2
9 files changed, 34 insertions, 17 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 1e7f3f9aeb8..aa62cab7c3d 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -1946,11 +1946,19 @@ Maybe you just misspelled the lint name or the lint doesn't exist anymore.
 Either way, try to update/remove it in order to fix the error.
 "##,
 
-E0611: r##"
-Lifetime parameter is missing in one of the function argument. Erroneous
-code example:
-
-```compile_fail,E0611
+E0621: r##"
+This error code indicates a mismatch between the function signature (i.e.,
+the parameter types and the return type) and the function body. Most of
+the time, this indicates that the function signature needs to be changed to
+match the body, but it may be that the body needs to be changed to match
+the signature.
+
+Specifically, one or more of the parameters contain borrowed data that
+needs to have a named lifetime in order for the body to type-check. Most of
+the time, this is because the borrowed data is being returned from the
+function, as in this example:
+
+```compile_fail,E0621
 fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 { // explicit lifetime required
                                              // in the type of `y`
     if x > y { x } else { y }
@@ -1959,15 +1967,24 @@ fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 { // explicit lifetime required
 fn main () { }
 ```
 
-Please add the missing lifetime parameter to remove this error. Example:
+Here, the function is returning data borrowed from either x or y, but the
+'a annotation indicates that it is returning data only from x. We can make
+the signature match the body by changing the type of y to &'a i32, like so:
 
 ```
 fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
     if x > y { x } else { y }
 }
 
-fn main() {
+fn main () { }
+```
+Alternatively, you could change the body not to return data from y:
+```
+fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
+    x
 }
+
+fn main () { }
 ```
 "##,
 
diff --git a/src/librustc/infer/error_reporting/named_anon_conflict.rs b/src/librustc/infer/error_reporting/named_anon_conflict.rs
index 4a1f4b418ae..fb0bd901db4 100644
--- a/src/librustc/infer/error_reporting/named_anon_conflict.rs
+++ b/src/librustc/infer/error_reporting/named_anon_conflict.rs
@@ -124,7 +124,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
         // Here we check for the case where anonymous region
         // corresponds to self and if yes, we display E0312.
         // FIXME(#42700) - Need to format self properly to
-        // enable E0611 for it.
+        // enable E0621 for it.
         if is_first &&
            self.tcx
                .opt_associated_item(scope_def_id)
@@ -136,7 +136,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
         if let Some(simple_name) = arg.pat.simple_name() {
             struct_span_err!(self.tcx.sess,
                              span,
-                             E0611,
+                             E0621,
                              "explicit lifetime required in the type of `{}`",
                              simple_name)
                     .span_label(arg.pat.span,
@@ -149,7 +149,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
         } else {
             struct_span_err!(self.tcx.sess,
                              span,
-                             E0611,
+                             E0621,
                              "explicit lifetime required in parameter type")
                     .span_label(arg.pat.span,
                                 format!("consider changing type to `{}`", new_ty))
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr
index ada7af8c1e4..4d8c5e039af 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr
@@ -1,4 +1,4 @@
-error[E0611]: explicit lifetime required in the type of `x`
+error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-2.rs:12:16
    |
 11 | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr
index 58aab711394..07b276601f4 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr
@@ -1,4 +1,4 @@
-error[E0611]: explicit lifetime required in parameter type
+error[E0621]: explicit lifetime required in parameter type
   --> $DIR/ex1-return-one-existing-name-if-else-3.rs:12:27
    |
 11 | fn foo<'a>((x, y): (&'a i32, &i32)) -> &'a i32 {
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr
index ec787eb749c..2adf0cd762c 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr
@@ -1,4 +1,4 @@
-error[E0611]: explicit lifetime required in the type of `x`
+error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-using-impl-2.rs:14:15
    |
 13 | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
index 502871022ff..15825017d15 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
@@ -1,4 +1,4 @@
-error[E0611]: explicit lifetime required in the type of `x`
+error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:18:36
    |
 16 |   fn foo<'a>(&'a self, x: &i32) -> &i32 {
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
index 837fa141bf1..892a6dcd1e9 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
@@ -1,4 +1,4 @@
-error[E0611]: explicit lifetime required in the type of `y`
+error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/ex1-return-one-existing-name-if-else.rs:12:27
    |
 11 | fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
diff --git a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr
index a16dac672ae..ea696c51d62 100644
--- a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr
+++ b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr
@@ -1,4 +1,4 @@
-error[E0611]: explicit lifetime required in the type of `x`
+error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex2a-push-one-existing-name-2.rs:16:12
    |
 15 | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
diff --git a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr
index 537090aa67d..1630ae32ba6 100644
--- a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr
+++ b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr
@@ -1,4 +1,4 @@
-error[E0611]: explicit lifetime required in the type of `y`
+error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/ex2a-push-one-existing-name.rs:16:12
    |
 15 | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {