-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk
Fix internal `default_hash_types` lint to use resolved path I run into false positives now and then (mostly in Clippy) when I want to name some util after HashMap.
- Loading branch information
Showing
8 changed files
with
72 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
// compile-flags: -Z unstable-options | ||
|
||
#![feature(rustc_private)] | ||
#![deny(rustc::default_hash_types)] | ||
|
||
extern crate rustc_data_structures; | ||
|
||
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; | ||
use std::collections::{HashMap, HashSet}; | ||
|
||
#[deny(rustc::default_hash_types)] | ||
mod foo { | ||
pub struct HashMap; | ||
} | ||
|
||
fn main() { | ||
let _map: HashMap<String, String> = HashMap::default(); | ||
//~^ ERROR Prefer FxHashMap over HashMap, it has better performance | ||
//~^^ ERROR Prefer FxHashMap over HashMap, it has better performance | ||
//~^ ERROR prefer `FxHashMap` over `HashMap`, it has better performance | ||
//~^^ ERROR prefer `FxHashMap` over `HashMap`, it has better performance | ||
let _set: HashSet<String> = HashSet::default(); | ||
//~^ ERROR Prefer FxHashSet over HashSet, it has better performance | ||
//~^^ ERROR Prefer FxHashSet over HashSet, it has better performance | ||
//~^ ERROR prefer `FxHashSet` over `HashSet`, it has better performance | ||
//~^^ ERROR prefer `FxHashSet` over `HashSet`, it has better performance | ||
|
||
// 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(); | ||
|
||
// test another struct of the same name | ||
let _ = foo::HashMap; | ||
} |
30 changes: 15 additions & 15 deletions
30
src/test/ui-fulldeps/internal-lints/default_hash_types.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters