From 5f0d46cd48c9281b3502d5aa2047124f3ee6b2e0 Mon Sep 17 00:00:00 2001 From: Marcin S Date: Thu, 3 Jan 2019 19:07:21 +0100 Subject: [PATCH] Add ui/for_kv_map test for false positive in #1279 --- tests/ui/for_kv_map.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/ui/for_kv_map.rs b/tests/ui/for_kv_map.rs index d79ea4bebeb5..549187756abd 100644 --- a/tests/ui/for_kv_map.rs +++ b/tests/ui/for_kv_map.rs @@ -42,15 +42,18 @@ fn main() { for (k, _value) in rm { let _k = k; } - test_for_kv_map(); -} -fn test_for_kv_map() { - let m: HashMap = HashMap::new(); + // The following should not produce warnings. + let m: HashMap = HashMap::new(); // No error, _value is actually used for (k, _value) in &m { let _ = _value; let _k = k; } + + let m: HashMap = Default::default(); + for (_, v) in m { + let _v = v; + } }