From 1812707d39a9ec62581509638f438cb48e2af13f Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 13 Aug 2018 08:23:07 +0100 Subject: [PATCH] Use utils::span_lint_and_sugg in default_hash_types --- clippy_lints/src/utils/internal_lints.rs | 4 ++-- tests/ui/fxhash.stderr | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 2e948ee6077..0da3ad83b84 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -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()); } } } diff --git a/tests/ui/fxhash.stderr b/tests/ui/fxhash.stderr index dc08ab88bac..5e90f84f1db 100644 --- a/tests/ui/fxhash.stderr +++ b/tests/ui/fxhash.stderr @@ -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 = 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 = 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 = 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 = HashSet::default(); - | ^^^^^^^ + | ^^^^^^^ help: use: `FxHashSet` error: aborting due to 6 previous errors