add expansion checks to iter_without_into_iter and into_iter_without_iter
This commit is contained in:
parent
174a0d7be6
commit
0848e120b2
5 changed files with 140 additions and 17 deletions
|
|
@ -5,7 +5,8 @@ use clippy_utils::ty::{implements_trait, make_normalized_projection};
|
|||
use rustc_ast::Mutability;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{FnRetTy, ImplItemKind, ImplicitSelfKind, ItemKind, TyKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::{sym, Symbol};
|
||||
|
|
@ -152,7 +153,8 @@ fn adt_has_inherent_method(cx: &LateContext<'_>, ty: Ty<'_>, method_name: Symbol
|
|||
|
||||
impl LateLintPass<'_> for IterWithoutIntoIter {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, item: &rustc_hir::Item<'_>) {
|
||||
if let ItemKind::Impl(imp) = item.kind
|
||||
if !in_external_macro(cx.sess(), item.span)
|
||||
&& let ItemKind::Impl(imp) = item.kind
|
||||
&& let TyKind::Ref(_, self_ty_without_ref) = &imp.self_ty.kind
|
||||
&& let Some(trait_ref) = imp.of_trait
|
||||
&& trait_ref
|
||||
|
|
@ -219,7 +221,8 @@ impl {self_ty_without_ref} {{
|
|||
_ => return,
|
||||
};
|
||||
|
||||
if let ImplItemKind::Fn(sig, _) = item.kind
|
||||
if !in_external_macro(cx.sess(), item.span)
|
||||
&& let ImplItemKind::Fn(sig, _) = item.kind
|
||||
&& let FnRetTy::Return(ret) = sig.decl.output
|
||||
&& is_nameable_in_impl_trait(ret)
|
||||
&& cx.tcx.generics_of(item_did).params.is_empty()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue