about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-09 21:53:57 +0000
committerbors <bors@rust-lang.org>2024-05-09 21:53:57 +0000
commit68dbc84ec49ef9a2d3f34973ec7a6c5e8cfa26e7 (patch)
tree514e50522e6ff1f962f6941f17cf948a85c5e5e1
parentbaf2a23840ffe2e4de7f57eb992e3dae675281c2 (diff)
parentcd00f5b9e48419563d6d44f68b24de218c0f39e5 (diff)
downloadrust-68dbc84ec49ef9a2d3f34973ec7a6c5e8cfa26e7.tar.gz
rust-68dbc84ec49ef9a2d3f34973ec7a6c5e8cfa26e7.zip
Auto merge of #12780 - future-highway:str-to-string-expansions, r=Manishearth
Ignore `_to_string` lints in code `from_expansion`

Includes the `string_to_string` and `str_to_string` lints.

changelog: [`str_to_string`]: Ignore code from expansion
changelog: [`string_to_string`]: Ignore code from expansion
-rw-r--r--clippy_lints/src/strings.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs
index 87a3c3874d7..292124196ff 100644
--- a/clippy_lints/src/strings.rs
+++ b/clippy_lints/src/strings.rs
@@ -389,6 +389,10 @@ declare_lint_pass!(StrToString => [STR_TO_STRING]);
 
 impl<'tcx> LateLintPass<'tcx> for StrToString {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
+        if expr.span.from_expansion() {
+            return;
+        }
+
         if let ExprKind::MethodCall(path, self_arg, ..) = &expr.kind
             && path.ident.name == sym::to_string
             && let ty = cx.typeck_results().expr_ty(self_arg)
@@ -437,6 +441,10 @@ declare_lint_pass!(StringToString => [STRING_TO_STRING]);
 
 impl<'tcx> LateLintPass<'tcx> for StringToString {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
+        if expr.span.from_expansion() {
+            return;
+        }
+
         if let ExprKind::MethodCall(path, self_arg, ..) = &expr.kind
             && path.ident.name == sym::to_string
             && let ty = cx.typeck_results().expr_ty(self_arg)