Rename contains_adt to contains_adt_constructor

This commit is contained in:
Jason Newcomb 2021-03-24 16:19:27 -04:00
parent 99b8a67198
commit 6e88900f9e
No known key found for this signature in database
GPG Key ID: DA59E8643A37ED06
2 changed files with 6 additions and 6 deletions

View File

@ -61,7 +61,7 @@ mod zst_offset;
use bind_instead_of_map::BindInsteadOfMap;
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
use clippy_utils::ty::{contains_adt, contains_ty, implements_trait, is_copy, is_type_diagnostic_item};
use clippy_utils::ty::{contains_adt_constructor, contains_ty, implements_trait, is_copy, is_type_diagnostic_item};
use clippy_utils::{contains_return, get_trait_def_id, in_macro, iter_input_pats, method_calls, paths, return_ty};
use if_chain::if_chain;
use rustc_hir as hir;
@ -1917,7 +1917,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
// walk the return type and check for Self (this does not check associated types)
if let Some(self_adt) = self_ty.ty_adt_def() {
if contains_adt(ret_ty, self_adt) {
if contains_adt_constructor(ret_ty, self_adt) {
return;
}
} else if contains_ty(ret_ty, self_ty) {
@ -1931,7 +1931,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
if let ty::PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
// walk the associated type and check for Self
if let Some(self_adt) = self_ty.ty_adt_def() {
if contains_adt(projection_predicate.ty, self_adt) {
if contains_adt_constructor(projection_predicate.ty, self_adt) {
return;
}
} else if contains_ty(projection_predicate.ty, self_ty) {

View File

@ -43,9 +43,9 @@ pub fn contains_ty(ty: Ty<'_>, other_ty: Ty<'_>) -> bool {
})
}
/// Walks into `ty` and returns `true` if any inner type is any instance of the given abstract data
/// type.`
pub fn contains_adt(ty: Ty<'_>, adt: &AdtDef) -> bool {
/// Walks into `ty` and returns `true` if any inner type is an instance of the given adt
/// constructor.
pub fn contains_adt_constructor(ty: Ty<'_>, adt: &AdtDef) -> bool {
ty.walk().any(|inner| match inner.unpack() {
GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt),
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,