]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / suggest-mut-method-for-loop-hashmap.rs
1 // run-rustfix
2 // https://github.com/rust-lang/rust/issues/82081
3
4 use std::collections::HashMap;
5
6 struct Test {
7     v: u32,
8 }
9
10 fn main() {
11     let mut map = HashMap::new();
12     map.insert("a", Test { v: 0 });
13
14     for (_k, mut v) in map.iter() {
15         //~^ HELP use mutable method
16         //~| NOTE this iterator yields `&` references
17         v.v += 1;
18         //~^ ERROR cannot assign to `v.v`
19         //~| NOTE `v` is a `&` reference
20     }
21 }