diff options
| author | bors <bors@rust-lang.org> | 2021-07-13 15:06:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-13 15:06:10 +0000 |
| commit | 3e1c75c6e25a4db968066bd2ef2dabc7c504d7ca (patch) | |
| tree | 30bfe071b15297a0d7c41b4cd1e2a0c05e07c56c /src/test/ui-fulldeps | |
| parent | ca99e3eb3adf61573b11d859ce2b9ff7db48ccd4 (diff) | |
| parent | 17ebba70d00e94b5136171d3f26d6a0369e7b83c (diff) | |
| download | rust-3e1c75c6e25a4db968066bd2ef2dabc7c504d7ca.tar.gz rust-3e1c75c6e25a4db968066bd2ef2dabc7c504d7ca.zip | |
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.
Diffstat (limited to 'src/test/ui-fulldeps')
| -rw-r--r-- | src/test/ui-fulldeps/internal-lints/default_hash_types.rs | 17 | ||||
| -rw-r--r-- | src/test/ui-fulldeps/internal-lints/default_hash_types.stderr | 30 |
2 files changed, 27 insertions, 20 deletions
diff --git a/src/test/ui-fulldeps/internal-lints/default_hash_types.rs b/src/test/ui-fulldeps/internal-lints/default_hash_types.rs index 3786c6de7e7..795c7d2dcb7 100644 --- a/src/test/ui-fulldeps/internal-lints/default_hash_types.rs +++ b/src/test/ui-fulldeps/internal-lints/default_hash_types.rs @@ -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; } diff --git a/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr b/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr index 4f78f51b676..9d13ee89bca 100644 --- a/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr +++ b/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr @@ -1,37 +1,37 @@ -error: Prefer FxHashMap over HashMap, it has better performance - --> $DIR/default_hash_types.rs:12:15 +error: prefer `FxHashMap` over `HashMap`, it has better performance + --> $DIR/default_hash_types.rs:16:41 | LL | let _map: HashMap<String, String> = HashMap::default(); - | ^^^^^^^ help: use: `FxHashMap` + | ^^^^^^^ | note: the lint level is defined here - --> $DIR/default_hash_types.rs:10:8 + --> $DIR/default_hash_types.rs:4:9 | -LL | #[deny(rustc::default_hash_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rustc::default_hash_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: a `use rustc_data_structures::fx::FxHashMap` may be necessary -error: Prefer FxHashMap over HashMap, it has better performance - --> $DIR/default_hash_types.rs:12:41 +error: prefer `FxHashMap` over `HashMap`, it has better performance + --> $DIR/default_hash_types.rs:16:15 | LL | let _map: HashMap<String, String> = HashMap::default(); - | ^^^^^^^ help: use: `FxHashMap` + | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: a `use rustc_data_structures::fx::FxHashMap` may be necessary -error: Prefer FxHashSet over HashSet, it has better performance - --> $DIR/default_hash_types.rs:15:15 +error: prefer `FxHashSet` over `HashSet`, it has better performance + --> $DIR/default_hash_types.rs:19:33 | LL | let _set: HashSet<String> = HashSet::default(); - | ^^^^^^^ help: use: `FxHashSet` + | ^^^^^^^ | = note: a `use rustc_data_structures::fx::FxHashSet` may be necessary -error: Prefer FxHashSet over HashSet, it has better performance - --> $DIR/default_hash_types.rs:15:33 +error: prefer `FxHashSet` over `HashSet`, it has better performance + --> $DIR/default_hash_types.rs:19:15 | LL | let _set: HashSet<String> = HashSet::default(); - | ^^^^^^^ help: use: `FxHashSet` + | ^^^^^^^^^^^^^^^ | = note: a `use rustc_data_structures::fx::FxHashSet` may be necessary |
