Fix false positive with new_ret_no_self when returning Self with different generic arguments
This commit is contained in:
parent
917b538c68
commit
99b8a67198
3 changed files with 31 additions and 4 deletions
|
|
@ -11,7 +11,7 @@ use rustc_hir::{TyKind, Unsafety};
|
|||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
|
||||
use rustc_middle::ty::{self, IntTy, Ty, TypeFoldable, UintTy};
|
||||
use rustc_middle::ty::{self, AdtDef, IntTy, Ty, TypeFoldable, UintTy};
|
||||
use rustc_span::sym;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
|
@ -43,6 +43,15 @@ 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 {
|
||||
ty.walk().any(|inner| match inner.unpack() {
|
||||
GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt),
|
||||
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns true if ty has `iter` or `iter_mut` methods
|
||||
pub fn has_iter_method(cx: &LateContext<'_>, probably_ref_ty: Ty<'_>) -> Option<Symbol> {
|
||||
// FIXME: instead of this hard-coded list, we should check if `<adt>::iter`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue