diff options
| author | future-highway <113635015+future-highway@users.noreply.github.com> | 2024-05-08 09:35:29 -0400 |
|---|---|---|
| committer | future-highway <113635015+future-highway@users.noreply.github.com> | 2024-05-08 09:35:29 -0400 |
| commit | cd00f5b9e48419563d6d44f68b24de218c0f39e5 (patch) | |
| tree | 0e1cacbc0b38a3732517b7cc3ed6f4a49a027154 | |
| parent | 30b3b73aa67f686db7370e490bf830ab2ddca8d6 (diff) | |
| download | rust-cd00f5b9e48419563d6d44f68b24de218c0f39e5.tar.gz rust-cd00f5b9e48419563d6d44f68b24de218c0f39e5.zip | |
Ignore `_to_string` lints in code `from_expansion`
Includes the `string_to_string` and `str_to_string` lints.
| -rw-r--r-- | clippy_lints/src/strings.rs | 8 |
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) |
