1- use crate :: utils:: {
2- match_def_path, match_type, paths, span_help_and_lint, span_lint, span_lint_and_sugg, walk_ptrs_ty,
3- } ;
1+ use crate :: utils:: { match_def_path, match_type, paths, span_help_and_lint, span_lint, walk_ptrs_ty} ;
42use if_chain:: if_chain;
53use rustc:: hir;
64use rustc:: hir:: def:: Def ;
@@ -9,8 +7,7 @@ use rustc::hir::*;
97use rustc:: lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintArray , LintPass } ;
108use rustc:: { declare_tool_lint, lint_array} ;
119use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
12- use rustc_errors:: Applicability ;
13- use syntax:: ast:: { Crate as AstCrate , Ident , ItemKind , Name } ;
10+ use syntax:: ast:: { Crate as AstCrate , ItemKind , Name } ;
1411use syntax:: source_map:: Span ;
1512use syntax:: symbol:: LocalInternedString ;
1613
@@ -56,17 +53,6 @@ declare_clippy_lint! {
5653 "declaring a lint without associating it in a LintPass"
5754}
5855
59- declare_clippy_lint ! {
60- /// **What it does:** Checks for the presence of the default hash types "HashMap" or "HashSet"
61- /// and recommends the FxHash* variants.
62- ///
63- /// **Why is this bad?** The FxHash variants have better performance
64- /// and we don't need any collision prevention in clippy.
65- pub DEFAULT_HASH_TYPES ,
66- internal,
67- "forbid HashMap and HashSet and suggest the FxHash* variants"
68- }
69-
7056declare_clippy_lint ! {
7157 /// **What it does:** Checks for calls to `cx.span_lint*` and suggests to use the `utils::*`
7258 /// variant of the function.
@@ -238,51 +224,6 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for LintCollector<'a, 'tcx> {
238224 }
239225}
240226
241- pub struct DefaultHashTypes {
242- map : FxHashMap < String , String > ,
243- }
244-
245- impl DefaultHashTypes {
246- pub fn default ( ) -> Self {
247- let mut map = FxHashMap :: default ( ) ;
248- map. insert ( "HashMap" . to_string ( ) , "FxHashMap" . to_string ( ) ) ;
249- map. insert ( "HashSet" . to_string ( ) , "FxHashSet" . to_string ( ) ) ;
250- Self { map }
251- }
252- }
253-
254- impl LintPass for DefaultHashTypes {
255- fn get_lints ( & self ) -> LintArray {
256- lint_array ! ( DEFAULT_HASH_TYPES )
257- }
258-
259- fn name ( & self ) -> & ' static str {
260- "DefaultHashType"
261- }
262- }
263-
264- impl EarlyLintPass for DefaultHashTypes {
265- fn check_ident ( & mut self , cx : & EarlyContext < ' _ > , ident : Ident ) {
266- let ident_string = ident. to_string ( ) ;
267- if let Some ( replace) = self . map . get ( & ident_string) {
268- let msg = format ! (
269- "Prefer {} over {}, it has better performance \
270- and we don't need any collision prevention in clippy",
271- replace, ident_string
272- ) ;
273- span_lint_and_sugg (
274- cx,
275- DEFAULT_HASH_TYPES ,
276- ident. span ,
277- & msg,
278- "use" ,
279- replace. to_string ( ) ,
280- Applicability :: MaybeIncorrect , // FxHashMap, ... needs another import
281- ) ;
282- }
283- }
284- }
285-
286227#[ derive( Clone , Default ) ]
287228pub struct CompilerLintFunctions {
288229 map : FxHashMap < String , String > ,
@@ -325,7 +266,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CompilerLintFunctions {
325266 COMPILER_LINT_FUNCTIONS ,
326267 path. ident. span,
327268 "usage of a compiler lint function" ,
328- & format!( "Please use the Clippy variant of this function: `{}`" , sugg) ,
269+ & format!( "please use the Clippy variant of this function: `{}`" , sugg) ,
329270 ) ;
330271 }
331272 }
0 commit comments