Merge pull request #3026 from dwijnand/fxhash
Add an internal lint for FxHashMap/FxHashSet
This commit is contained in:
commit
84aa49935d
4 changed files with 104 additions and 2 deletions
16
tests/ui/fxhash.rs
Normal file
16
tests/ui/fxhash.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#![warn(default_hash_types)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_data_structures;
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
|
||||
fn main() {
|
||||
let _map: HashMap<String, String> = HashMap::default();
|
||||
let _set: HashSet<String> = HashSet::default();
|
||||
|
||||
// test that the lint doesn't also match the Fx variants themselves 😂
|
||||
let _fx_map: FxHashMap<String, String> = FxHashMap::default();
|
||||
let _fx_set: FxHashSet<String> = FxHashSet::default();
|
||||
}
|
||||
40
tests/ui/fxhash.stderr
Normal file
40
tests/ui/fxhash.stderr
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:6:24
|
||||
|
|
||||
6 | use std::collections::{HashMap, HashSet};
|
||||
| ^^^^^^^ help: use: `FxHashMap`
|
||||
|
|
||||
= note: `-D default-hash-types` implied by `-D warnings`
|
||||
|
||||
error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:6:33
|
||||
|
|
||||
6 | use std::collections::{HashMap, HashSet};
|
||||
| ^^^^^^^ help: use: `FxHashSet`
|
||||
|
||||
error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:10:15
|
||||
|
|
||||
10 | let _map: HashMap<String, String> = HashMap::default();
|
||||
| ^^^^^^^ help: use: `FxHashMap`
|
||||
|
||||
error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:10:41
|
||||
|
|
||||
10 | let _map: HashMap<String, String> = HashMap::default();
|
||||
| ^^^^^^^ help: use: `FxHashMap`
|
||||
|
||||
error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:11:15
|
||||
|
|
||||
11 | let _set: HashSet<String> = HashSet::default();
|
||||
| ^^^^^^^ help: use: `FxHashSet`
|
||||
|
||||
error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:11:33
|
||||
|
|
||||
11 | let _set: HashSet<String> = HashSet::default();
|
||||
| ^^^^^^^ help: use: `FxHashSet`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue