Skip to content

Commit

Permalink
Unrolled build for rust-lang#123247
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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.
  • Loading branch information
rust-timer authored Apr 30, 2024
2 parents a743116 + 26ed429 commit c0ca90c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions compiler/rustc_error_codes/src/error_codes/E0637.md
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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
Expand All @@ -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>,
{
}
```
Expand Down

0 comments on commit c0ca90c

Please sign in to comment.