Skip to content

Commit 1812707

Browse files
committed
Use utils::span_lint_and_sugg in default_hash_types
1 parent 8fc425b commit 1812707

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

clippy_lints/src/utils/internal_lints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc::hir::*;
44
use rustc::hir;
55
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
66
use rustc_data_structures::fx::FxHashMap;
7-
use crate::utils::{match_qpath, paths, span_lint};
7+
use crate::utils::{match_qpath, paths, span_lint, span_lint_and_sugg};
88
use syntax::symbol::LocalInternedString;
99
use syntax::ast::{Crate as AstCrate, Ident, ItemKind, Name};
1010
use syntax::codemap::Span;
@@ -247,7 +247,7 @@ impl EarlyLintPass for DefaultHashTypes {
247247
let ident_string = ident.to_string();
248248
if let Some(replace) = self.map.get(&ident_string) {
249249
let msg = format!("Prefer {} over {}, it has better performance and we don't need any collision prevention in clippy", replace, ident_string);
250-
cx.span_lint(DEFAULT_HASH_TYPES, ident.span, &msg);
250+
span_lint_and_sugg(cx, DEFAULT_HASH_TYPES, ident.span, &msg, "use", replace.to_owned());
251251
}
252252
}
253253
}

tests/ui/fxhash.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@ error: Prefer FxHashMap over HashMap, it has better performance and we don't nee
22
--> $DIR/fxhash.rs:6:24
33
|
44
6 | use std::collections::{HashMap, HashSet};
5-
| ^^^^^^^
5+
| ^^^^^^^ help: use: `FxHashMap`
66
|
77
= note: `-D default-hash-types` implied by `-D warnings`
88

99
error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy
1010
--> $DIR/fxhash.rs:6:33
1111
|
1212
6 | use std::collections::{HashMap, HashSet};
13-
| ^^^^^^^
13+
| ^^^^^^^ help: use: `FxHashSet`
1414

1515
error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy
1616
--> $DIR/fxhash.rs:10:15
1717
|
1818
10 | let _map: HashMap<String, String> = HashMap::default();
19-
| ^^^^^^^
19+
| ^^^^^^^ help: use: `FxHashMap`
2020

2121
error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy
2222
--> $DIR/fxhash.rs:10:41
2323
|
2424
10 | let _map: HashMap<String, String> = HashMap::default();
25-
| ^^^^^^^
25+
| ^^^^^^^ help: use: `FxHashMap`
2626

2727
error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy
2828
--> $DIR/fxhash.rs:11:15
2929
|
3030
11 | let _set: HashSet<String> = HashSet::default();
31-
| ^^^^^^^
31+
| ^^^^^^^ help: use: `FxHashSet`
3232

3333
error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy
3434
--> $DIR/fxhash.rs:11:33
3535
|
3636
11 | let _set: HashSet<String> = HashSet::default();
37-
| ^^^^^^^
37+
| ^^^^^^^ help: use: `FxHashSet`
3838

3939
error: aborting due to 6 previous errors
4040

0 commit comments

Comments
 (0)