mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 11:12:43 +00:00
add tests for type-aliased hash types
This commit is contained in:
parent
938984a24e
commit
f8ea496495
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user