]> git.lizzy.rs Git - rust.git/commitdiff
Added long error description & modifed error_codes.rs
authorJosh White <josh@animind.space>
Wed, 5 Feb 2020 11:28:31 +0000 (06:28 -0500)
committerJosh White <jwhite927@gmail.com>
Thu, 6 Feb 2020 21:18:24 +0000 (16:18 -0500)
src/librustc_error_codes/error_codes.rs
src/librustc_error_codes/error_codes/E0637.md [new file with mode: 0644]

index c3d9ed088981d432042be43a590de0428b1da85b..ba43b29538d50dcd85b5f42ed14ed637251adb9d 100644 (file)
 E0633: include_str!("./error_codes/E0633.md"),
 E0635: include_str!("./error_codes/E0635.md"),
 E0636: include_str!("./error_codes/E0636.md"),
+E0637: include_str!("./error_codes/E0637.md"),
 E0638: include_str!("./error_codes/E0638.md"),
 E0639: include_str!("./error_codes/E0639.md"),
 E0641: include_str!("./error_codes/E0641.md"),
     E0632, // cannot provide explicit generic arguments when `impl Trait` is
            // used in argument position
     E0634, // type has conflicting packed representaton hints
-    E0637, // "'_" is not a valid lifetime bound
     E0640, // infer outlives requirements
 //  E0645, // trait aliases not finished
     E0657, // `impl Trait` can only capture lifetimes bound at the fn level
diff --git a/src/librustc_error_codes/error_codes/E0637.md b/src/librustc_error_codes/error_codes/E0637.md
new file mode 100644 (file)
index 0000000..4f139b0
--- /dev/null
@@ -0,0 +1,22 @@
+The underscore `_` character has been used as the identifier for a lifetime. 
+
+Erroneous code example:
+```
+fn some_function<'_>(x: &'_ str, y: &'_ str) -> &'_ str {
+    //Some code
+}
+```
+
+Lifetimes are named with 'ident, where ident is the name of the 
+lifetime or loop. The `_` character, which represents the ignore pattern, 
+cannot be used because it is a reserved lifetime name. 
+To fix this, use a single lowercase letter as the 
+lifetime identifier, such as `'a`. For more information, see [The Rust Book](https://doc.rust-lang.org/stable/book/appendix-02-operators.html#non-operator-symbols).
+
+Corrected code example:
+```
+fn some_function<'a>(x: &'a str, y: &'a str) -> &'a str {
+    //Some code
+}
+```
+