summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/iter_kv_map.fixed
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/tests/ui/iter_kv_map.fixed35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/tools/clippy/tests/ui/iter_kv_map.fixed b/src/tools/clippy/tests/ui/iter_kv_map.fixed
index 83fee0408..f2a4c284c 100644
--- a/src/tools/clippy/tests/ui/iter_kv_map.fixed
+++ b/src/tools/clippy/tests/ui/iter_kv_map.fixed
@@ -1,14 +1,15 @@
// run-rustfix
#![warn(clippy::iter_kv_map)]
-#![allow(clippy::redundant_clone)]
-#![allow(clippy::suspicious_map)]
-#![allow(clippy::map_identity)]
+#![allow(unused_mut, clippy::redundant_clone, clippy::suspicious_map, clippy::map_identity)]
use std::collections::{BTreeMap, HashMap};
fn main() {
let get_key = |(key, _val)| key;
+ fn ref_acceptor(v: &u32) -> u32 {
+ *v
+ }
let map: HashMap<u32, u32> = HashMap::new();
@@ -36,6 +37,20 @@ fn main() {
let _ = map.keys().map(|key| key * 9).count();
let _ = map.values().map(|value| value * 17).count();
+ // Preserve the ref in the fix.
+ let _ = map.clone().into_values().map(|ref val| ref_acceptor(val)).count();
+
+ // Preserve the mut in the fix.
+ let _ = map
+ .clone().into_values().map(|mut val| {
+ val += 2;
+ val
+ })
+ .count();
+
+ // Don't let a mut interfere.
+ let _ = map.clone().into_values().count();
+
let map: BTreeMap<u32, u32> = BTreeMap::new();
let _ = map.keys().collect::<Vec<_>>();
@@ -61,4 +76,18 @@ fn main() {
// Lint
let _ = map.keys().map(|key| key * 9).count();
let _ = map.values().map(|value| value * 17).count();
+
+ // Preserve the ref in the fix.
+ let _ = map.clone().into_values().map(|ref val| ref_acceptor(val)).count();
+
+ // Preserve the mut in the fix.
+ let _ = map
+ .clone().into_values().map(|mut val| {
+ val += 2;
+ val
+ })
+ .count();
+
+ // Don't let a mut interfere.
+ let _ = map.clone().into_values().count();
}