-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add beginner friendly lifetime elision hint to E0623 #90179
Add beginner friendly lifetime elision hint to E0623 #90179
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
Outdated
Show resolved
Hide resolved
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.
Thank you so much for doing this! It is great! I have some nitpicks below, but none of them are a dealbreaker. Would you have time to address them?
compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
Outdated
Show resolved
Hide resolved
I will remove the tests that cause the double error reporting so that rustfix can apply the correct fix for all test cases. I'll add some other ones that shoudn't have this issue but test the new suggestions just as well. |
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit 76ec1aa has been approved by |
…-hint, r=estebank Add beginner friendly lifetime elision hint to E0623 Address rust-lang#90170 Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't. Example: ``` error[E0623]: lifetime mismatch --> $DIR/issue-90170-elision-mismatch.rs:2:35 | LL | fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) { | --------- --------- these two types are declared with different lifetimes... LL | core::mem::swap(&mut slice_a, &mut slice_b); | ^^^^^^^^^^^^ ...but data from `slice_b` flows into `slice_a` here | = note: Each elided lifetime in input position becomes a distinct lifetime. help: Explicitly declare a lifetime and assign it to both | LL | fn foo<'a>(slice_a: &'a mut [u8], slice_b: &'a mut [u8]) { | ++++ ++ ++ ``` for ```rust fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) { core::mem::swap(&mut slice_a, &mut slice_b); } ```
Some tests failed in a rollup: #90325 (comment) |
I'm a bit confused about why the rollup failed, I updated my fork and my local repository, I have the most recent commit of master, but the tests pass. |
Have you tried doing |
I tried it now, the tests still pass and |
Can you run |
I ran it, the test still passed. I also cloned my fork into a fresh directory again and rebuilt everything, but the lifetime tests still pass. |
Even with |
Yes, even with the flag |
Should we try to include this in the next rollup again and see whether it works, or what's your idea for it? |
@bors retry rollup=iffy |
:( |
Repeating my comment from zulip here in case you missed it. This PR adds a new test, and it apparently has different diagnostics under NLL, making the PR fail as you've noticed in the previous comments. The fact that the command Esteban showed works on your machine makes me think that you could locally have the file that the UI tests expect ? That command should have created a |
510e2e3
to
e8b6cc3
Compare
Also repeat from zulip Oh I think I just found the issue. Two tests have always been failing (ui/linkage-attr/issue-10755.rs and ui/process/process-spawn-nonexistent.rs) (I should probably open an issue) so I've just been ignoring that fact. I just added the ignore-test attribute to them and turns out, there is some more stuff that is ran after they fail, for example thje NLL tests. I've now got the .nll.stderr and I hope this will fix everything! Oh man this is so dumb, but I'm glad that I finally fixed it, thank you for your help! |
This comment has been minimized.
This comment has been minimized.
oops, that was an accident |
i hope i fixed everything, I'm sorry that the last commit is now on top, but it's gits fault for making rebase conflicts so weird :( |
Last nitpick: if you do a rebase again and squash all commits into one, it will be easier to look at the involved files history in the future and there will be no longer any "weird log history". I normally leave the commits independent during review and squash into commits containing logical grouped changes. In this case a single commit should be fine. If you try locally and find difficulties doing this, don't worry, let me know and I'll merge as is, but I'd prefer squashing these. |
Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't Issue rust-lang#90170 This also changes the tests introduced by the previous commits because of another rustc issue (rust-lang#90258)
2e91e9e
to
4b9e460
Compare
So, that's it, let's hope this finally works!😅 |
@bors r+ |
📌 Commit 4b9e460 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (e60e19b): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Address #90170
Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't.
Example:
for