Skip to content

Commit 8e2ddc8

Browse files
committed
inherent_to_string: Check HIR tree before checking for macros.
1 parent a413281 commit 8e2ddc8

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

clippy_lints/src/inherent_to_string.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ declare_lint_pass!(InherentToString => [INHERENT_TO_STRING, INHERENT_TO_STRING_S
9191

9292
impl<'tcx> LateLintPass<'tcx> for InherentToString {
9393
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
94-
if impl_item.span.from_expansion() {
95-
return;
96-
}
97-
9894
// Check if item is a method called `to_string` and has a parameter 'self'
9995
if let ImplItemKind::Fn(ref signature, _) = impl_item.kind
10096
// #11201
@@ -106,6 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
106102
&& decl.implicit_self.has_implicit_self()
107103
&& decl.inputs.len() == 1
108104
&& impl_item.generics.params.iter().all(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }))
105+
&& !impl_item.span.from_expansion()
109106
// Check if return type is String
110107
&& is_type_lang_item(cx, return_ty(cx, impl_item.owner_id), LangItem::String)
111108
// Filters instances of to_string which are required by a trait

0 commit comments

Comments
 (0)