-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Improve diagnostics when a static lifetime is expected #90667
Improve diagnostics when a static lifetime is expected #90667
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
r? rust-lang/diagnostics |
📌 Commit 60767b8 has been approved by |
…ostics, r=estebank Improve diagnostics when a static lifetime is expected Makes progress towards rust-lang#90600 The diagnostics here were previously entirely removed due to giving a misleading suggestion but if we instead provide an informative label in that same location it should better help the user understand the situation. I included the example from the issue as it demonstrates an area where the diagnostics are still lacking. Happy to remove that if its just adding noise atm.
…ostics, r=estebank Improve diagnostics when a static lifetime is expected Makes progress towards rust-lang#90600 The diagnostics here were previously entirely removed due to giving a misleading suggestion but if we instead provide an informative label in that same location it should better help the user understand the situation. I included the example from the issue as it demonstrates an area where the diagnostics are still lacking. Happy to remove that if its just adding noise atm.
Looks like there are some test failures. Please check |
Ah, so I need to specify |
60767b8
to
130b9e9
Compare
Ready for review, the PR is completely rewritten so you should rereview from scratch. I ran the following to ensure the tests are passing: RUST_BACKTRACE=0 ./x.py test src/test/ui --stage 1 --force-rerun --compare-mode nll
RUST_BACKTRACE=0 ./x.py test src/test/ui --stage 1 --force-rerun Observed problems in the new diagnostics.1nll is missing the "captured here" notes that migrate gives, e.g.
2The nll diagnostics always name the lifetimes (e.g. `1) even when there is only one lifetime. 3The nll diagnostics say:
Considering you cant outlive `static, in this case it might make more sense to say:
But it seems none of the diagnostics are regressing in value so any potentital fixes for these can go in follow up PRs. If the listed problems make sense to you then I'll file a seperate issue for each of them. Strange UI testregions-static-bound has stderr files named like |
LL | t | ||
| ^ | ||
| | ||
= note: ...the reference is valid for the static lifetime... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we're not looking at the bounds in the where
clause to look for the source of 'static
requirement. Not necessary on this PR.
@bors r+ |
📌 Commit 130b9e9 has been approved by |
⌛ Testing commit 130b9e9 with merge ae2a20556c445da16259c236637c61ed92e2cb63... |
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
@bors retry |
@rukai: 🔑 Insufficient privileges: not in try users |
@bors retry |
…askrgr Rollup of 8 pull requests Successful merges: - rust-lang#89610 (warn on must_use use on async fn's) - rust-lang#90667 (Improve diagnostics when a static lifetime is expected) - rust-lang#90687 (Permit const panics in stable const contexts in stdlib) - rust-lang#90772 (Add Vec::retain_mut) - rust-lang#90861 (Print escaped string if char literal has multiple characters, but only one printable character) - rust-lang#90884 (Fix span for non-satisfied trivial trait bounds) - rust-lang#90900 (Remove workaround for the forward progress handling in LLVM) - rust-lang#90901 (Improve ManuallyDrop suggestion) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
… r=cjgillot Remove FIXME about NLL diagnostic that is already improved The FIXME was added in rust-lang#46984 when the diagnostic message looked like this: // FIXME(rust-lang#46983): error message should be better &s.0 //~ ERROR free region `` does not outlive free region `'static` The message was improved in rust-lang#90667 and now looks like this: &s.0 //~ ERROR lifetime may not live long enough but the FIXME was not removed. The issue rust-lang#46983 about that diagnostics should be improved has been closed. We can remove the FIXME now. (This PR was made for rust-lang#44366.)
Makes progress towards #90600
The diagnostics here were previously entirely removed due to giving a misleading suggestion but if we instead provide an informative label in that same location it should better help the user understand the situation.
I included the example from the issue as it demonstrates an area where the diagnostics are still lacking.
Happy to remove that if its just adding noise atm.