]> git.lizzy.rs Git - rust.git/commitdiff
Added proper explanation of ErrorCode-E0687
authorpankajchaudhary5 <pankajchaudhary172@gmail.com>
Sun, 10 May 2020 06:09:51 +0000 (11:39 +0530)
committerpankajchaudhary5 <pankajchaudhary172@gmail.com>
Sun, 14 Jun 2020 17:27:19 +0000 (22:57 +0530)
src/librustc_error_codes/error_codes.rs
src/librustc_error_codes/error_codes/E0687.md [new file with mode: 0644]
src/test/ui/in-band-lifetimes/E0687.stderr
src/test/ui/in-band-lifetimes/E0687_where.stderr

index 225ede851b4d93a4eb960cda277a5fe6dc3586f9..c54cb81b00dbe7505427ffb31ae12013f2e94b96 100644 (file)
 E0669: include_str!("./error_codes/E0669.md"),
 E0670: include_str!("./error_codes/E0670.md"),
 E0671: include_str!("./error_codes/E0671.md"),
+E0687: include_str!("./error_codes/E0687.md"),
 E0689: include_str!("./error_codes/E0689.md"),
 E0690: include_str!("./error_codes/E0690.md"),
 E0691: include_str!("./error_codes/E0691.md"),
     E0640, // infer outlives requirements
 //  E0645, // trait aliases not finished
     E0667, // `impl Trait` in projections
-    E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
     E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
 //  E0694, // an unknown tool name found in scoped attributes
     E0696, // `continue` pointing to a labeled block
diff --git a/src/librustc_error_codes/error_codes/E0687.md b/src/librustc_error_codes/error_codes/E0687.md
new file mode 100644 (file)
index 0000000..67b7db2
--- /dev/null
@@ -0,0 +1,36 @@
+In-band lifetimes cannot be used in `fn`/`Fn` syntax.
+
+Erroneous code examples:
+
+```compile_fail,E0687
+#![feature(in_band_lifetimes)]
+
+fn foo(x: fn(&'a u32)) {} // error!
+
+fn bar(x: &Fn(&'a u32)) {} // error!
+
+fn baz(x: fn(&'a u32), y: &'a u32) {} // error!
+
+struct Foo<'a> { x: &'a u32 }
+
+impl Foo<'a> {
+    fn bar(&self, x: fn(&'a u32)) {} // error!
+}
+```
+
+Lifetimes used in `fn` or `Fn` syntax must be explicitly
+declared using `<...>` binders. For example:
+
+```
+fn foo<'a>(x: fn(&'a u32)) {} // ok!
+
+fn bar<'a>(x: &Fn(&'a u32)) {} // ok!
+
+fn baz<'a>(x: fn(&'a u32), y: &'a u32) {} // ok!
+
+struct Foo<'a> { x: &'a u32 }
+
+impl<'a> Foo<'a> {
+    fn bar(&self, x: fn(&'a u32)) {} // ok!
+}
+```
index e8e5100e00e0773b0c08bd62e0ced028d21c5b66..7aea2f220466c53a0a0aed36d390b3a433d9b2fe 100644 (file)
@@ -24,3 +24,4 @@ LL |     fn bar(&self, x: fn(&'a u32)) {}
 
 error: aborting due to 4 previous errors
 
+For more information about this error, try `rustc --explain E0687`.
index b422869c4db89235e9c865cb3e0308b442465441..af0f9665f5d06df7ded816bc7e4b9bde522a8ffd 100644 (file)
@@ -12,3 +12,4 @@ LL | fn baz(x: &impl Fn(&'a u32)) {}
 
 error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0687`.