From d6b0d0bf9746a441e5082415e7f929af2874b65a Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Fri, 2 Jul 2021 14:15:11 -0500 Subject: Fix default_hash_types to use resolved path --- .../internal-lints/default_hash_types.rs | 17 ++++++++---- .../internal-lints/default_hash_types.stderr | 30 +++++++++++----------- src/test/ui/lint/issue-83477.rs | 3 +-- src/test/ui/lint/issue-83477.stderr | 6 ++--- 4 files changed, 31 insertions(+), 25 deletions(-) (limited to 'src') 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 = 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 = 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 = FxHashMap::default(); let _fx_set: FxHashSet = 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 = 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 = 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 = 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 = HashSet::default(); - | ^^^^^^^ help: use: `FxHashSet` + | ^^^^^^^^^^^^^^^ | = note: a `use rustc_data_structures::fx::FxHashSet` may be necessary diff --git a/src/test/ui/lint/issue-83477.rs b/src/test/ui/lint/issue-83477.rs index ab62f0c8b8c..4262a28799d 100644 --- a/src/test/ui/lint/issue-83477.rs +++ b/src/test/ui/lint/issue-83477.rs @@ -12,6 +12,5 @@ //~| SUGGESTION rustc::default_hash_types fn main() { let _ = std::collections::HashMap::::new(); - //~^ WARN Prefer FxHashMap over HashMap, it has better performance - //~| HELP use + //~^ WARN prefer `FxHashMap` over `HashMap`, it has better performance } diff --git a/src/test/ui/lint/issue-83477.stderr b/src/test/ui/lint/issue-83477.stderr index 028890f3623..e619bcfe23f 100644 --- a/src/test/ui/lint/issue-83477.stderr +++ b/src/test/ui/lint/issue-83477.stderr @@ -12,11 +12,11 @@ warning: unknown lint: `rustc::foo::default_hash_types` LL | #[allow(rustc::foo::default_hash_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `rustc::default_hash_types` -warning: Prefer FxHashMap over HashMap, it has better performance - --> $DIR/issue-83477.rs:14:31 +warning: prefer `FxHashMap` over `HashMap`, it has better performance + --> $DIR/issue-83477.rs:14:13 | LL | let _ = std::collections::HashMap::::new(); - | ^^^^^^^ help: use: `FxHashMap` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/issue-83477.rs:3:9 -- cgit 1.4.1-3-g733a5 From 17ebba70d00e94b5136171d3f26d6a0369e7b83c Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Thu, 8 Jul 2021 12:59:16 -0500 Subject: clippy: allow default_hash_types on bootstrap --- src/tools/clippy/clippy_lints/src/implicit_hasher.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/clippy/clippy_lints/src/implicit_hasher.rs b/src/tools/clippy/clippy_lints/src/implicit_hasher.rs index 03fe0d16d48..9a040ca572a 100644 --- a/src/tools/clippy/clippy_lints/src/implicit_hasher.rs +++ b/src/tools/clippy/clippy_lints/src/implicit_hasher.rs @@ -1,4 +1,4 @@ -#![allow(rustc::default_hash_types)] +#![cfg_attr(bootstrap, allow(rustc::default_hash_types))] use std::borrow::Cow; use std::collections::BTreeMap; -- cgit 1.4.1-3-g733a5