Skip to content

Improve borrow of immutable indexed content with NLL enabled #53228

Closed
@estebank

Description

@estebank

Follow up on #52788 and produce the following output when enabling NLL:

error[E0596]: cannot borrow immutable indexed content as mutable
  --> $DIR/index-mut-help.rs:21:5
   |
LL |     map["peter"].clear();           //~ ERROR
   |     ^^^^^^^^^^^^ cannot borrow as mutable
   |
   = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>`

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsNLL-diagnosticsWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions