@@ -3,11 +3,12 @@ use clippy_utils::paths::{PathNS, lookup_path_str};
33use clippy_utils:: sym;
44use clippy_utils:: ty:: { get_field_by_name, implements_trait, ty_from_hir_ty} ;
55use rustc_errors:: MultiSpan ;
6- use rustc_hir:: { Body , ExprKind , Impl , ImplItemKind , Item , ItemKind , OwnerId , OwnerNode } ;
6+ use rustc_hir:: { Body , ExprKind , Impl , ImplItemKind , Item , ItemKind , OwnerId , OwnerNode , QPath } ;
77use rustc_lint:: { LateContext , LateLintPass } ;
88use rustc_session:: impl_lint_pass;
99use rustc_span:: def_id:: DefId ;
1010use rustc_span:: sym as rustc_sym;
11+ use rustc_span:: symbol:: kw;
1112
1213declare_clippy_lint ! {
1314 /// ### What it does
@@ -151,7 +152,10 @@ impl<'tcx> LateLintPass<'tcx> for IterMissingExactSize {
151152 && let Some ( trailing_expr) = block. expr
152153 && let ExprKind :: MethodCall ( method_name, receiver, args, _) = trailing_expr. kind
153154 && method_name. ident . name == sym:: size_hint
154- && let ExprKind :: Field ( _object, field_name) = receiver. kind
155+ && let ExprKind :: Field ( object, field_name) = receiver. kind
156+ && let ExprKind :: Path ( QPath :: Resolved ( _, object_path) ) = object. kind
157+ && let [ path_segment] = object_path. segments
158+ && path_segment. ident . name == kw:: SelfLower
155159 && args. is_empty ( )
156160 {
157161 // The function body is just `self.{field}.size_hint()`, check
0 commit comments