Skip to content
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

“type must outlive the static lifetime” makes no sense #41816

Open
nagisa opened this issue May 7, 2017 · 6 comments
Open

“type must outlive the static lifetime” makes no sense #41816

nagisa opened this issue May 7, 2017 · 6 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nagisa
Copy link
Member

nagisa commented May 7, 2017

For the following code

pub trait Arbitrary: Sized + 'static {}

impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {}

The diagnostic looks like this:

error[E0477]: the type `std::borrow::Cow<'a, A>` does not fulfill the required lifetime
 --> <anon>:3:20
  |
3 | impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {}
  |                    ^^^^^^^^^
  |
  = note: type must outlive the static lifetime

The note here makes no sense, because the static lifetime is the longest lifetime of all and cannot really be outlived. We should reword the note so it doesn’t say “outlive”.

Bonus points for explaining where the lifetime requirement comes from, because it is not entirely clear what here introduces the requirement, when the trait and implementation definitions aren’t so close together.

@nagisa nagisa added the A-diagnostics Area: Messages for errors, warnings, and lints label May 7, 2017
@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented May 9, 2017

I'll fix the simple version.

PS: and try to do the big part later on.

@nagisa
Copy link
Member Author

nagisa commented May 9, 2017

In addition to everything, the span is pretty bad. The type which must satisfy any of the lifetimes here is the implementor, not the trait.

frewsxcv added a commit to frewsxcv/rust that referenced this issue May 10, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 10, 2017
bors added a commit that referenced this issue May 10, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@steveklabnik
Copy link
Member

Triage; this now says

  = note: but lifetime parameter must outlive the static lifetime

So, not fixed yet!

@crlf0710 crlf0710 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 11, 2020
@gilescope
Copy link
Contributor

Still makes not much sense in 2022.

@hnyls2002
Copy link

Still makes not much sense in 2023

hnyls2002 added a commit to hnyls2002/TRustAss that referenced this issue Jul 19, 2023
@lrettig
Copy link

lrettig commented Jun 26, 2024

Still makes not much sense in 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants