]> git.lizzy.rs Git - rust.git/blob - tests/ui-fulldeps/internal-lints/default_hash_types.rs
Rollup merge of #106958 - jyn514:labels, r=m-ou-se
[rust.git] / tests / ui-fulldeps / internal-lints / default_hash_types.rs
1 // compile-flags: -Z unstable-options
2
3 #![feature(rustc_private)]
4 #![deny(rustc::default_hash_types)]
5
6 extern crate rustc_data_structures;
7
8 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
9 use std::collections::{HashMap, HashSet};
10
11 mod foo {
12     pub struct HashMap;
13 }
14
15 fn main() {
16     let _map: HashMap<String, String> = HashMap::default();
17     //~^ ERROR prefer `FxHashMap` over `HashMap`, it has better performance
18     //~^^ ERROR prefer `FxHashMap` over `HashMap`, it has better performance
19     let _set: HashSet<String> = HashSet::default();
20     //~^ ERROR prefer `FxHashSet` over `HashSet`, it has better performance
21     //~^^ ERROR prefer `FxHashSet` over `HashSet`, it has better performance
22
23     // test that the lint doesn't also match the Fx variants themselves
24     let _fx_map: FxHashMap<String, String> = FxHashMap::default();
25     let _fx_set: FxHashSet<String> = FxHashSet::default();
26
27     // test another struct of the same name
28     let _ = foo::HashMap;
29 }