diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-30 15:04:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-30 15:04:08 +0200 |
| commit | 7427812261469c52f7093722746c26b134d39bd0 (patch) | |
| tree | 4057a310dccf9e7db22321bb5b4c633ac230c1fe | |
| parent | 47314eb427e1a9fb4f347cbeb44729486b6dbf53 (diff) | |
| parent | 26ed429bab12b71891defd0f8191d2b651164f4e (diff) | |
| download | rust-7427812261469c52f7093722746c26b134d39bd0.tar.gz rust-7427812261469c52f7093722746c26b134d39bd0.zip | |
Rollup merge of #123247 - veera-sivarajan:fix-error-code-E0637-example-code, r=fmease
Mention Both HRTB and Generic Lifetime Param in `E0637` documentation The compiler (rustc 1.77.0) error for `and_without_explicit_lifetime()` in the erroneous code example suggests using a HRTB. But, the corrected example uses an explicit lifetime parameter. This PR fixes it so that the documentation and the compiler suggestion for error code `E0637` are consistent with each other.
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0637.md | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0637.md b/compiler/rustc_error_codes/src/error_codes/E0637.md index 62d5565df27..9c2a53f51cf 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0637.md +++ b/compiler/rustc_error_codes/src/error_codes/E0637.md @@ -1,5 +1,5 @@ `'_` lifetime name or `&T` without an explicit lifetime name has been used -on illegal place. +in an illegal place. Erroneous code example: @@ -13,7 +13,14 @@ fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str { } } -fn and_without_explicit_lifetime<T>() +fn without_explicit_lifetime<T>() +where + T: Iterator<Item = &u32>, + //^ `&` without an explicit lifetime name +{ +} + +fn without_hrtb<T>() where T: Into<&u32>, //^ `&` without an explicit lifetime name @@ -40,9 +47,15 @@ fn underscore_lifetime<'a>(str1: &'a str, str2: &'a str) -> &'a str { } } -fn and_without_explicit_lifetime<'foo, T>() +fn without_explicit_lifetime<'a, T>() +where + T: Iterator<Item = &'a u32>, +{ +} + +fn without_hrtb<T>() where - T: Into<&'foo u32>, + T: for<'foo> Into<&'foo u32>, { } ``` |
