diff --git a/tests/ui/iter_over_hash_type.rs b/tests/ui/iter_over_hash_type.rs index 9c3f5d337528..7000c8bf96f8 100644 --- a/tests/ui/iter_over_hash_type.rs +++ b/tests/ui/iter_over_hash_type.rs @@ -1,15 +1,20 @@ //@aux-build:proc_macros.rs - +#![feature(rustc_private)] #![warn(clippy::iter_over_hash_type)] use std::collections::{HashMap, HashSet}; +extern crate rustc_data_structures; + extern crate proc_macros; fn main() { let mut hash_set = HashSet::::new(); let mut hash_map = HashMap::::new(); + let mut fx_hash_map = rustc_data_structures::fx::FxHashMap::::default(); + let mut fx_hash_set = rustc_data_structures::fx::FxHashMap::::default(); let vec = Vec::::new(); + // test hashset for x in &hash_set { let _ = x; } @@ -22,6 +27,8 @@ fn main() { for x in hash_set.drain() { let _ = x; } + + // test hashmap for (x, y) in &hash_map { let _ = (x, y); } @@ -44,6 +51,14 @@ fn main() { let _ = x; } + // test type-aliased hashers + for x in fx_hash_set { + let _ = x; + } + for x in fx_hash_map { + let _ = x; + } + // shouldnt fire for x in &vec { let _ = x; diff --git a/tests/ui/iter_over_hash_type.stderr b/tests/ui/iter_over_hash_type.stderr index 1204b88d2834..cf420fb8e996 100644 --- a/tests/ui/iter_over_hash_type.stderr +++ b/tests/ui/iter_over_hash_type.stderr @@ -1,5 +1,5 @@ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:13:5 + --> $DIR/iter_over_hash_type.rs:18:5 | LL | / for x in &hash_set { LL | | let _ = x; @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::iter_over_hash_type)]` error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:16:5 + --> $DIR/iter_over_hash_type.rs:21:5 | LL | / for x in hash_set.iter() { LL | | let _ = x; @@ -18,7 +18,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:19:5 + --> $DIR/iter_over_hash_type.rs:24:5 | LL | / for x in hash_set.clone() { LL | | let _ = x; @@ -26,7 +26,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:22:5 + --> $DIR/iter_over_hash_type.rs:27:5 | LL | / for x in hash_set.drain() { LL | | let _ = x; @@ -34,7 +34,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:25:5 + --> $DIR/iter_over_hash_type.rs:32:5 | LL | / for (x, y) in &hash_map { LL | | let _ = (x, y); @@ -42,7 +42,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:28:5 + --> $DIR/iter_over_hash_type.rs:35:5 | LL | / for x in hash_map.keys() { LL | | let _ = x; @@ -50,7 +50,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:31:5 + --> $DIR/iter_over_hash_type.rs:38:5 | LL | / for x in hash_map.values() { LL | | let _ = x; @@ -58,7 +58,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:34:5 + --> $DIR/iter_over_hash_type.rs:41:5 | LL | / for x in hash_map.values_mut() { LL | | *x += 1; @@ -66,7 +66,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:37:5 + --> $DIR/iter_over_hash_type.rs:44:5 | LL | / for x in hash_map.iter() { LL | | let _ = x; @@ -74,7 +74,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:40:5 + --> $DIR/iter_over_hash_type.rs:47:5 | LL | / for x in hash_map.clone() { LL | | let _ = x; @@ -82,12 +82,28 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:43:5 + --> $DIR/iter_over_hash_type.rs:50:5 | LL | / for x in hash_map.drain() { LL | | let _ = x; LL | | } | |_____^ -error: aborting due to 11 previous errors +error: iteration over unordered hash-based type + --> $DIR/iter_over_hash_type.rs:55:5 + | +LL | / for x in fx_hash_set { +LL | | let _ = x; +LL | | } + | |_____^ + +error: iteration over unordered hash-based type + --> $DIR/iter_over_hash_type.rs:58:5 + | +LL | / for x in fx_hash_map { +LL | | let _ = x; +LL | | } + | |_____^ + +error: aborting due to 13 previous errors