-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsNLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This happens in a lot of tests, but from src/test/ui/traits/trait-upcasting/type-checking-test-4.rs:
before
error[E0308]: mismatched types
--> $DIR/type-checking-test-4.rs:20:13
|
LL | let _ = x as &dyn Bar<'static, 'a>; // Error
| ^ lifetime mismatch
|
= note: expected trait object `dyn Bar<'static, 'a>`
found trait object `dyn Bar<'static, 'static>`
note: the lifetime `'a` as defined here...
--> $DIR/type-checking-test-4.rs:19:16
|
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
| ^^
= note: ...does not necessarily outlive the static lifetime
after
error: lifetime may not live long enough
--> $DIR/type-checking-test-4.rs:20:13
|
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
| -- lifetime `'a` defined here
LL | let _ = x as &dyn Bar<'static, 'a>; // Error
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
Being able to compare the expected and found types in full make it clear what's wrong.
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsNLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.