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

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

Open
jackh726 opened this issue May 22, 2022 · 1 comment
Open

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

jackh726 opened this issue May 22, 2022 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jackh726
Copy link
Member

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.

@jackh726 jackh726 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal labels May 22, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue May 22, 2022
Move remaining tests with NLL differences to revisions

Based on rust-lang#97206

I've already filed issues for any important differences that I've spotted: rust-lang#97252 rust-lang#97253 rust-lang#97256 rust-lang#97267

There is a lot here, but each commit is self-contained as a separate directory. I can split into separate PRs as wanted or needed.
@compiler-errors
Copy link
Member

compiler-errors commented Jun 5, 2022

I looked into this one. Seems like there's not really a good way of getting a TypeTrace to find out what subtyping relation caused 'a: 'static to be required...

All we have a really bare struct ConstraintCategory that characterizes the region constraint. That's where we get the wording type annotation requires that [...] -- maybe we could make ConstraintCategory carry more info?

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 A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal 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

2 participants