Skip to content

document for E0502 insufficiently general #126495

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

Closed
yg-i opened this issue Jun 14, 2024 · 0 comments · Fixed by #127410
Closed

document for E0502 insufficiently general #126495

yg-i opened this issue Jun 14, 2024 · 0 comments · Fixed by #127410
Labels
A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@yg-i
Copy link

yg-i commented Jun 14, 2024

Location

Location is E0502.md, the explanation for Error code E0502

https://github.com/rust-lang/rust/blob/master/compiler/rustc_error_codes/src/error_codes/E0502.md

online version: https://doc.rust-lang.org/error_codes/E0502.html

Summary

The doc explains E0502 as follows:

A variable already borrowed as immutable was borrowed as mutable.

However, E0502 is also emitted when a variable already borrowed as mutable was borrowed as immutable. E.g. see line 1 and 13 in this file

1     error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
...
13    error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable

So it seems a more general explanation might be advisable that covers (at least) both types of cases.

@yg-i yg-i added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Jun 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 14, 2024
@jieyouxu jieyouxu 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. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. A-borrow-checker Area: The borrow checker and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 16, 2024
@bors bors closed this as completed in 9352026 Jul 6, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 6, 2024
Rollup merge of rust-lang#127410 - trevyn:patch-1, r=compiler-errors

Correct description of E0502

Closes rust-lang#126495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants