diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2024-06-12 13:01:12 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2024-07-07 16:35:05 -0400 |
| commit | 8e2ddc800b2e89d3a5df1dd9373ddea6e8d9fe42 (patch) | |
| tree | 1078d2c196479e869183a34cfea1f0ac5adfc8e3 | |
| parent | a4132817fbdd6ca3b67c7b012b9751ea78cdba05 (diff) | |
| download | rust-8e2ddc800b2e89d3a5df1dd9373ddea6e8d9fe42.tar.gz rust-8e2ddc800b2e89d3a5df1dd9373ddea6e8d9fe42.zip | |
`inherent_to_string`: Check HIR tree before checking for macros.
| -rw-r--r-- | clippy_lints/src/inherent_to_string.rs | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index 9aedf5ec7e8..ec6174bc030 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -91,10 +91,6 @@ declare_lint_pass!(InherentToString => [INHERENT_TO_STRING, INHERENT_TO_STRING_S impl<'tcx> LateLintPass<'tcx> for InherentToString { fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) { - if impl_item.span.from_expansion() { - return; - } - // Check if item is a method called `to_string` and has a parameter 'self' if let ImplItemKind::Fn(ref signature, _) = impl_item.kind // #11201 @@ -106,6 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString { && decl.implicit_self.has_implicit_self() && decl.inputs.len() == 1 && impl_item.generics.params.iter().all(|p| matches!(p.kind, GenericParamKind::Lifetime { .. })) + && !impl_item.span.from_expansion() // Check if return type is String && is_type_lang_item(cx, return_ty(cx, impl_item.owner_id), LangItem::String) // Filters instances of to_string which are required by a trait |
