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} ;
4
2
use if_chain:: if_chain;
5
3
use rustc:: hir;
6
4
use rustc:: hir:: def:: Def ;
@@ -9,8 +7,7 @@ use rustc::hir::*;
9
7
use rustc:: lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintArray , LintPass } ;
10
8
use rustc:: { declare_tool_lint, lint_array} ;
11
9
use 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 } ;
14
11
use syntax:: source_map:: Span ;
15
12
use syntax:: symbol:: LocalInternedString ;
16
13
@@ -56,17 +53,6 @@ declare_clippy_lint! {
56
53
"declaring a lint without associating it in a LintPass"
57
54
}
58
55
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
-
70
56
declare_clippy_lint ! {
71
57
/// **What it does:** Checks for calls to `cx.span_lint*` and suggests to use the `utils::*`
72
58
/// variant of the function.
@@ -238,51 +224,6 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for LintCollector<'a, 'tcx> {
238
224
}
239
225
}
240
226
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
-
286
227
#[ derive( Clone , Default ) ]
287
228
pub struct CompilerLintFunctions {
288
229
map : FxHashMap < String , String > ,
@@ -325,7 +266,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CompilerLintFunctions {
325
266
COMPILER_LINT_FUNCTIONS ,
326
267
path. ident. span,
327
268
"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) ,
329
270
) ;
330
271
}
331
272
}
0 commit comments