forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#95433 - Dylan-DPC:rollup-xdfit9h, r=Dylan-DPC
Rollup of 4 pull requests Successful merges: - rust-lang#94566 (Show ignore message in console and json output) - rust-lang#95415 (diagnostics: regression test for HashMap iter_mut suggestion) - rust-lang#95422 (Refactor: Use `format-args-capture` and remove an unnecessary nested block) - rust-lang#95424 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
6 changed files
with
93 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/ui/suggestions/suggest-mut-method-for-loop-hashmap.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// run-rustfix | ||
// https://github.com/rust-lang/rust/issues/82081 | ||
|
||
use std::collections::HashMap; | ||
|
||
struct Test { | ||
v: u32, | ||
} | ||
|
||
fn main() { | ||
let mut map = HashMap::new(); | ||
map.insert("a", Test { v: 0 }); | ||
|
||
for (_k, mut v) in map.iter_mut() { | ||
//~^ HELP use mutable method | ||
//~| NOTE this iterator yields `&` references | ||
v.v += 1; | ||
//~^ ERROR cannot assign to `v.v` | ||
//~| NOTE `v` is a `&` reference | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/suggestions/suggest-mut-method-for-loop-hashmap.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// run-rustfix | ||
// https://github.com/rust-lang/rust/issues/82081 | ||
|
||
use std::collections::HashMap; | ||
|
||
struct Test { | ||
v: u32, | ||
} | ||
|
||
fn main() { | ||
let mut map = HashMap::new(); | ||
map.insert("a", Test { v: 0 }); | ||
|
||
for (_k, mut v) in map.iter() { | ||
//~^ HELP use mutable method | ||
//~| NOTE this iterator yields `&` references | ||
v.v += 1; | ||
//~^ ERROR cannot assign to `v.v` | ||
//~| NOTE `v` is a `&` reference | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0594]: cannot assign to `v.v`, which is behind a `&` reference | ||
--> $DIR/suggest-mut-method-for-loop-hashmap.rs:17:9 | ||
| | ||
LL | for (_k, mut v) in map.iter() { | ||
| ---------- | ||
| | | | ||
| | help: use mutable method: `iter_mut()` | ||
| this iterator yields `&` references | ||
... | ||
LL | v.v += 1; | ||
| ^^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be written | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0594`. |
Submodule rust-analyzer
updated
from b594f9 to bc08b8