Skip to content

Mention Both HRTB and Generic Lifetime Param in E0637 documentation #123247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading