about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2021-03-17 12:33:09 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2021-03-18 00:51:18 +0900
commit3d9b45df0fa6bc04d864aa4a67fdb631b9bf0a99 (patch)
treeb51afe3f5427392b0e106b87f5889cd8339426bd
parent48430849465ae94255e78f895197b09c2ce3b03e (diff)
downloadrust-3d9b45df0fa6bc04d864aa4a67fdb631b9bf0a99.tar.gz
rust-3d9b45df0fa6bc04d864aa4a67fdb631b9bf0a99.zip
move single_char_add_str to its own module
-rw-r--r--clippy_lints/src/methods/single_char_add_str.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/clippy_lints/src/methods/single_char_add_str.rs b/clippy_lints/src/methods/single_char_add_str.rs
new file mode 100644
index 00000000000..3df88e5b69c
--- /dev/null
+++ b/clippy_lints/src/methods/single_char_add_str.rs
@@ -0,0 +1,15 @@
+use crate::methods::{single_char_insert_string, single_char_push_string};
+use crate::utils::match_def_path;
+use crate::utils::paths;
+use rustc_hir as hir;
+use rustc_lint::LateContext;
+
+pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) {
+    if let Some(fn_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) {
+        if match_def_path(cx, fn_def_id, &paths::PUSH_STR) {
+            single_char_push_string::check(cx, expr, args);
+        } else if match_def_path(cx, fn_def_id, &paths::INSERT_STR) {
+            single_char_insert_string::check(cx, expr, args);
+        }
+    }
+}