-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Missing implied bound raises misleading error message #127900
Comments
Error
|
This is confusing but I don't think it is a bug, I am sure there is an open issue for it somewhere... Maybe we could improve the diagnostics at least to explain "so that the type |
Pretty sure the underlying bug is #105495 (implied bounds from impl header are not used when checking assoc items for well-formedness) |
Right, but that's immaterial. It's not super relevant if the implied bound stems from an inferred or explicit outlives-bound ( |
OTOH, turning the implied bound into an explicit bound in the impl header (as opposed to updating - impl<'a, T> Foo<'a, T> {
+ impl<'a, T: 'a> Foo<'a, T> { |
I'm not sure if that really makes sense usage wise, shouldn't a constant have a static lifetime anyway? |
I tried this code:
I expected to see this happen: There should not be an error, the constant should have been evaluated as a literal. Using a literal does not raise the error.
Instead, this happened: Compile time error stating there is a lifetime issue. It requests a bound that shouldn't be neccessary. The error is misleading.
Meta
The bug occurs in my version and the latest stable.
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: