Open
Description
The following code playground link
use std::any::Any;
struct Something<'a> {
broken: Box<dyn Any + 'a>
}
Outputs an error message related to lifetime issues that is not clear what the issue exactly is.
error[E0478]: lifetime bound not satisfied
--> src/lib.rs:4:13
|
4 | broken: Box<dyn Any + 'a>
| ^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'a` as defined on the struct at 3:18
--> src/lib.rs:3:18
|
3 | struct Something<'a> {
| ^^
= note: but lifetime parameter must outlive the static lifetime
This error is caused by trait Any: 'static
, however this error message is not clear as to why the lifetime needs to outlive the static lifetime. Ideally the error message would say where the requirement comes from, like other lifetime-related errors.
cc @estebank who was looking for weird and unintuitive errors. This wasn't caused by a crate specifically, but it still isn't a good error.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: trait objects, vtable layoutArea: Lifetimes / regionsDiagnostics: Confusing error or lint that should be reworked.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.