diff options
| author | Jacherr <jwc2002@outlook.com> | 2023-11-13 16:48:52 +0000 |
|---|---|---|
| committer | Jacherr <jwc2002@outlook.com> | 2023-11-13 16:52:59 +0000 |
| commit | f8ea496495d2766536d7f0fe11c03d609e8ed837 (patch) | |
| tree | dc36e571968b162000dedf6857c4e1b62dae91ff | |
| parent | 938984a24e09b20bf972eff0a6e790b61b482b85 (diff) | |
| download | rust-f8ea496495d2766536d7f0fe11c03d609e8ed837.tar.gz rust-f8ea496495d2766536d7f0fe11c03d609e8ed837.zip | |
add tests for type-aliased hash types
| -rw-r--r-- | tests/ui/iter_over_hash_type.rs | 17 | ||||
| -rw-r--r-- | tests/ui/iter_over_hash_type.stderr | 40 |
2 files changed, 44 insertions, 13 deletions
diff --git a/tests/ui/iter_over_hash_type.rs b/tests/ui/iter_over_hash_type.rs index 9c3f5d33752..7000c8bf96f 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::<i32>::new(); let mut hash_map = HashMap::<i32, i32>::new(); + let mut fx_hash_map = rustc_data_structures::fx::FxHashMap::<i32, i32>::default(); + let mut fx_hash_set = rustc_data_structures::fx::FxHashMap::<i32, i32>::default(); let vec = Vec::<i32>::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 1204b88d283..cf420fb8e99 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 |
