Skip to content

document for E0502 insufficiently general #126495

Closed
@yg-i

Description

@yg-i

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-borrow-checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions