-
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
NLL: ui/E0501.rs refers to "first borrow" but not "second borrow" #55314
Comments
triage: P-medium |
Here are some mentoring instructions to get started on this issue. If you're reading this and want to give this issue a go, drop a comment here and feel free to ask for any help or clarification on Zulip. If this is your first contribution then there are instructions on getting a local build of the compiler available in the rustc guide. These pointers are up-to-date as of master being So, the function that handles reporting errors like this is rust/src/librustc_mir/borrow_check/error_reporting.rs Lines 323 to 329 in abe19a7
Normally you can find functions like this by grepping for the messages you see in the error. If we do that, we can grep for rust/src/librustc_mir/util/borrowck_errors.rs Lines 266 to 285 in 451987d
In this function, we can see a error being created and a label being added saying "borrow occurs here" - that must be where we want to prefix "second". We can see that function is being called from the first function I linked: rust/src/librustc_mir/borrow_check/error_reporting.rs Lines 448 to 458 in 451987d
We want to be careful though and make sure we only add "second" when there's something labelled "first". Just above the call site of that function, we see a rust/src/librustc_mir/borrow_check/error_reporting.rs Lines 516 to 517 in 451987d
If we look at the source for that function, then it looks like it adds more labels to our error and uses that prefix - however, it doesn't add any labels like that when it doesn't have an explanation (that is, the return value of So, what we'll want to do to fix this issue is move the computation of the borrow explanation (the call to If you've got this working then you should run the tests and update any that change correctly and then open a PR with a line saying |
I'll have a go at this 😄 |
…ref, r=davidtwco Refer to the second borrow as the "second borrow" in E0501.rs Fixes rust-lang#55314. r? @davidtwco
…ref, r=davidtwco Refer to the second borrow as the "second borrow" in E0501.rs Fixes rust-lang#55314. r? @davidtwco
…ref, r=davidtwco Refer to the second borrow as the "second borrow" in E0501.rs Fixes rust-lang#55314. r? @davidtwco
…ref, r=davidtwco Refer to the second borrow as the "second borrow" in E0501.rs Fixes rust-lang#55314. r? @davidtwco
…ref, r=davidtwco Refer to the second borrow as the "second borrow" in E0501.rs Fixes rust-lang#55314. r? @davidtwco
…ref, r=davidtwco Refer to the second borrow as the "second borrow" in E0501.rs Fixes rust-lang#55314. r? @davidtwco
…ref, r=davidtwco Refer to the second borrow as the "second borrow" in E0501.rs Fixes rust-lang#55314. r? @davidtwco
…ref, r=davidtwco Refer to the second borrow as the "second borrow" in E0501.rs Fixes rust-lang#55314. r? @davidtwco
This diagnostic output
rust/src/test/ui/E0501.ast.nll.stderr
Lines 1 to 13 in f99911a
is not a regression, per se. But we put in effort to identify something as the "first borrow" (rather than "previous borrow"); that means we should similarly identify the other borrow as the "second borrow".
The text was updated successfully, but these errors were encountered: