mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 05:56:56 +00:00
![]() ``` error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-1.rs:17:9 | LL | self.s.push('x'); | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference | LL | fn f(&mut self) { | +++ ``` Note the suggestion to add `mut` instead of replacing the entire `&self` with `&mut self`. |
||
---|---|---|
.. | ||
mut-cant-alias.rs | ||
mut-cant-alias.stderr | ||
mut-cross-borrowing.rs | ||
mut-cross-borrowing.stderr | ||
mut-pattern-internal-mutability.rs | ||
mut-pattern-internal-mutability.stderr | ||
mut-pattern-mismatched.rs | ||
mut-pattern-mismatched.stderr | ||
mut-ref.rs | ||
mut-suggestion.rs | ||
mut-suggestion.stderr | ||
mutable-class-fields-2.rs | ||
mutable-class-fields-2.stderr | ||
mutable-class-fields.rs | ||
mutable-class-fields.stderr | ||
mutable-enum-indirect.rs | ||
mutable-enum-indirect.stderr | ||
no-mut-lint-for-desugared-mut.rs |