Skip to content

Commit 71be6f6

Browse files
committed
Auto merge of #4177 - mikerite:compiler_lint_functions_fewer_strings, r=phansch
Remove `to_string()`s from CompilerLintFunctions changelog: none
2 parents 5be4e71 + b36d7a0 commit 71be6f6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

clippy_lints/src/utils/internal_lints.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,17 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for LintCollector<'a, 'tcx> {
213213

214214
#[derive(Clone, Default)]
215215
pub struct CompilerLintFunctions {
216-
map: FxHashMap<String, String>,
216+
map: FxHashMap<&'static str, &'static str>,
217217
}
218218

219219
impl CompilerLintFunctions {
220220
pub fn new() -> Self {
221221
let mut map = FxHashMap::default();
222-
map.insert("span_lint".to_string(), "utils::span_lint".to_string());
223-
map.insert("struct_span_lint".to_string(), "utils::span_lint".to_string());
224-
map.insert("lint".to_string(), "utils::span_lint".to_string());
225-
map.insert("span_lint_note".to_string(), "utils::span_note_and_lint".to_string());
226-
map.insert("span_lint_help".to_string(), "utils::span_help_and_lint".to_string());
222+
map.insert("span_lint", "utils::span_lint");
223+
map.insert("struct_span_lint", "utils::span_lint");
224+
map.insert("lint", "utils::span_lint");
225+
map.insert("span_lint_note", "utils::span_note_and_lint");
226+
map.insert("span_lint_help", "utils::span_help_and_lint");
227227
Self { map }
228228
}
229229
}
@@ -234,8 +234,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CompilerLintFunctions {
234234
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
235235
if_chain! {
236236
if let ExprKind::MethodCall(ref path, _, ref args) = expr.node;
237-
let fn_name = path.ident.as_str().to_string();
238-
if let Some(sugg) = self.map.get(&fn_name);
237+
let fn_name = path.ident;
238+
if let Some(sugg) = self.map.get(&*fn_name.as_str());
239239
let ty = walk_ptrs_ty(cx.tables.expr_ty(&args[0]));
240240
if match_type(cx, ty, &paths::EARLY_CONTEXT)
241241
|| match_type(cx, ty, &paths::LATE_CONTEXT);

0 commit comments

Comments
 (0)