mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-24 04:46:58 +00:00
inherent_to_string
: Check HIR tree before checking for macros.
This commit is contained in:
parent
a4132817fb
commit
8e2ddc800b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user