Skip to content

Commit

Permalink
Auto merge of #4177 - mikerite:compiler_lint_functions_fewer_strings,…
Browse files Browse the repository at this point in the history
… r=phansch

Remove `to_string()`s from CompilerLintFunctions

changelog: none
  • Loading branch information
bors committed Jun 6, 2019
2 parents 5be4e71 + b36d7a0 commit 71be6f6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions clippy_lints/src/utils/internal_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,17 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for LintCollector<'a, 'tcx> {

#[derive(Clone, Default)]
pub struct CompilerLintFunctions {
map: FxHashMap<String, String>,
map: FxHashMap<&'static str, &'static str>,
}

impl CompilerLintFunctions {
pub fn new() -> Self {
let mut map = FxHashMap::default();
map.insert("span_lint".to_string(), "utils::span_lint".to_string());
map.insert("struct_span_lint".to_string(), "utils::span_lint".to_string());
map.insert("lint".to_string(), "utils::span_lint".to_string());
map.insert("span_lint_note".to_string(), "utils::span_note_and_lint".to_string());
map.insert("span_lint_help".to_string(), "utils::span_help_and_lint".to_string());
map.insert("span_lint", "utils::span_lint");
map.insert("struct_span_lint", "utils::span_lint");
map.insert("lint", "utils::span_lint");
map.insert("span_lint_note", "utils::span_note_and_lint");
map.insert("span_lint_help", "utils::span_help_and_lint");
Self { map }
}
}
Expand All @@ -234,8 +234,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CompilerLintFunctions {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
if_chain! {
if let ExprKind::MethodCall(ref path, _, ref args) = expr.node;
let fn_name = path.ident.as_str().to_string();
if let Some(sugg) = self.map.get(&fn_name);
let fn_name = path.ident;
if let Some(sugg) = self.map.get(&*fn_name.as_str());
let ty = walk_ptrs_ty(cx.tables.expr_ty(&args[0]));
if match_type(cx, ty, &paths::EARLY_CONTEXT)
|| match_type(cx, ty, &paths::LATE_CONTEXT);
Expand Down

0 comments on commit 71be6f6

Please sign in to comment.