Skip to content

Conversation

estebank
Copy link
Contributor

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.

```
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`.
@rustbot
Copy link
Collaborator

rustbot commented Jan 28, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 28, 2025
@petrochenkov
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jan 28, 2025

📌 Commit 130b0d2 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 28, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jan 29, 2025
Tweak `&mut self` suggestion span

```
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`.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 29, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#133382 (Suggest considering casting fn item as fn pointer in more cases)
 - rust-lang#136092 (Test pipes also when not running on Windows and Linux simultaneously)
 - rust-lang#136190 (Remove duplicated code in RISC-V asm bad-reg test)
 - rust-lang#136192 (ci: remove unused windows runner)
 - rust-lang#136205 (Properly check that array length is valid type during built-in unsizing in index)
 - rust-lang#136211 (Update mdbook to 0.4.44)
 - rust-lang#136212 (Tweak `&mut self` suggestion span)
 - rust-lang#136214 (Make crate AST mutation accessible for driver callback)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1f6a9aa into rust-lang:master Jan 29, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 29, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 29, 2025
Rollup merge of rust-lang#136212 - estebank:span-tweak, r=petrochenkov

Tweak `&mut self` suggestion span

```
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`.
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request Mar 11, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#133382 (Suggest considering casting fn item as fn pointer in more cases)
 - rust-lang#136092 (Test pipes also when not running on Windows and Linux simultaneously)
 - rust-lang#136190 (Remove duplicated code in RISC-V asm bad-reg test)
 - rust-lang#136192 (ci: remove unused windows runner)
 - rust-lang#136205 (Properly check that array length is valid type during built-in unsizing in index)
 - rust-lang#136211 (Update mdbook to 0.4.44)
 - rust-lang#136212 (Tweak `&mut self` suggestion span)
 - rust-lang#136214 (Make crate AST mutation accessible for driver callback)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants