Skip to content

[NLL] No "expected ..., found ..." in diagnostics #97267

Description

@jackh726

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsNLL-diagnosticsWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions