Use utils::span_lint_and_sugg in default_hash_types
This commit is contained in:
parent
8fc425b676
commit
1812707d39
@ -4,7 +4,7 @@ use rustc::hir::*;
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use crate::utils::{match_qpath, paths, span_lint};
|
||||
use crate::utils::{match_qpath, paths, span_lint, span_lint_and_sugg};
|
||||
use syntax::symbol::LocalInternedString;
|
||||
use syntax::ast::{Crate as AstCrate, Ident, ItemKind, Name};
|
||||
use syntax::codemap::Span;
|
||||
@ -247,7 +247,7 @@ impl EarlyLintPass for DefaultHashTypes {
|
||||
let ident_string = ident.to_string();
|
||||
if let Some(replace) = self.map.get(&ident_string) {
|
||||
let msg = format!("Prefer {} over {}, it has better performance and we don't need any collision prevention in clippy", replace, ident_string);
|
||||
cx.span_lint(DEFAULT_HASH_TYPES, ident.span, &msg);
|
||||
span_lint_and_sugg(cx, DEFAULT_HASH_TYPES, ident.span, &msg, "use", replace.to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ error: Prefer FxHashMap over HashMap, it has better performance and we don't nee
|
||||
--> $DIR/fxhash.rs:6:24
|
||||
|
|
||||
6 | use std::collections::{HashMap, HashSet};
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ help: use: `FxHashMap`
|
||||
|
|
||||
= note: `-D default-hash-types` implied by `-D warnings`
|
||||
|
||||
@ -10,31 +10,31 @@ error: Prefer FxHashSet over HashSet, it has better performance and we don't nee
|
||||
--> $DIR/fxhash.rs:6:33
|
||||
|
|
||||
6 | use std::collections::{HashMap, HashSet};
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ help: use: `FxHashSet`
|
||||
|
||||
error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:10:15
|
||||
|
|
||||
10 | let _map: HashMap<String, String> = HashMap::default();
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ help: use: `FxHashMap`
|
||||
|
||||
error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:10:41
|
||||
|
|
||||
10 | let _map: HashMap<String, String> = HashMap::default();
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ help: use: `FxHashMap`
|
||||
|
||||
error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:11:15
|
||||
|
|
||||
11 | let _set: HashSet<String> = HashSet::default();
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ help: use: `FxHashSet`
|
||||
|
||||
error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy
|
||||
--> $DIR/fxhash.rs:11:33
|
||||
|
|
||||
11 | let _set: HashSet<String> = HashSet::default();
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ help: use: `FxHashSet`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user