From 0e9d260e0a53f9d92f09d0276d22b874aee98259 Mon Sep 17 00:00:00 2001 From: Philip Munksgaard Date: Sat, 15 Sep 2018 11:50:41 +0200 Subject: [PATCH] Improve output if no_lookup_host_duplicates fails If the test fails, output the offending addresses and a helpful error message. Also slightly improve legibility of the preceding line that puts the addresses into a HashMap. --- src/libstd/sys_common/net.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index b841afe1a51..d09a233ed89 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -622,7 +622,8 @@ fn no_lookup_host_duplicates() { Ok(lh) => lh, Err(e) => panic!("couldn't resolve `localhost': {}", e) }; - let _na = lh.map(|sa| *addrs.entry(sa).or_insert(0) += 1).count(); - assert!(addrs.values().filter(|&&v| v > 1).count() == 0); + for sa in lh { *addrs.entry(sa).or_insert(0) += 1; }; + assert_eq!(addrs.iter().filter(|&(_, &v)| v > 1).collect::>(), vec![], + "There should be no duplicate localhost entries"); } } -- 2.44.0