@@ -54,7 +54,7 @@ mod zst_offset;
54
54
use bind_instead_of_map:: BindInsteadOfMap ;
55
55
use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help, span_lint_and_sugg} ;
56
56
use clippy_utils:: source:: snippet_with_applicability;
57
- use clippy_utils:: ty:: { contains_ty, implements_trait, is_copy, is_type_diagnostic_item} ;
57
+ use clippy_utils:: ty:: { contains_adt , contains_ty, implements_trait, is_copy, is_type_diagnostic_item} ;
58
58
use clippy_utils:: {
59
59
contains_return, get_trait_def_id, in_macro, iter_input_pats, match_def_path, match_qpath, method_calls,
60
60
method_chain_args, paths, return_ty, single_segment_path, SpanlessEq ,
@@ -1907,7 +1907,11 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
1907
1907
let ret_ty = return_ty ( cx, impl_item. hir_id ( ) ) ;
1908
1908
1909
1909
// walk the return type and check for Self (this does not check associated types)
1910
- if contains_ty ( ret_ty, self_ty) {
1910
+ if let Some ( self_adt) = self_ty. ty_adt_def ( ) {
1911
+ if contains_adt ( ret_ty, self_adt) {
1912
+ return ;
1913
+ }
1914
+ } else if contains_ty ( ret_ty, self_ty) {
1911
1915
return ;
1912
1916
}
1913
1917
@@ -1917,7 +1921,11 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
1917
1921
for & ( predicate, _span) in cx. tcx . explicit_item_bounds ( def_id) {
1918
1922
if let ty:: PredicateKind :: Projection ( projection_predicate) = predicate. kind ( ) . skip_binder ( ) {
1919
1923
// walk the associated type and check for Self
1920
- if contains_ty ( projection_predicate. ty , self_ty) {
1924
+ if let Some ( self_adt) = self_ty. ty_adt_def ( ) {
1925
+ if contains_adt ( projection_predicate. ty , self_adt) {
1926
+ return ;
1927
+ }
1928
+ } else if contains_ty ( projection_predicate. ty , self_ty) {
1921
1929
return ;
1922
1930
}
1923
1931
}
0 commit comments