@@ -167,15 +167,15 @@ impl<'a, 'tcx> Visitor<'tcx> for ImplVisitor<'a, 'tcx> {
167
167
}
168
168
169
169
fn visit_expr ( & mut self , expr : & ' tcx Expr < ' tcx > ) {
170
+ fn expr_ty_matches < ' a , ' tcx > ( expr : & ' tcx Expr < ' tcx > , self_ty : Ty < ' tcx > , cx : & LateContext < ' a , ' tcx > ) -> bool {
171
+ cx. tcx
172
+ . typeck_tables_of ( expr. hir_id . owner . to_def_id ( ) )
173
+ . node_type ( expr. hir_id )
174
+ == self_ty
175
+ }
170
176
match expr. kind {
171
177
ExprKind :: Struct ( QPath :: Resolved ( _, path) , ..) => {
172
- if self
173
- . cx
174
- . tcx
175
- . typeck_tables_of ( expr. hir_id . owner . to_def_id ( ) )
176
- . node_type ( expr. hir_id )
177
- == self . self_ty
178
- {
178
+ if expr_ty_matches ( expr, self . self_ty , self . cx ) {
179
179
match path. res {
180
180
def:: Res :: SelfTy ( ..) => ( ) ,
181
181
def:: Res :: Def ( DefKind :: Variant , _) => span_lint_ignore_last_segment ( self . cx , path) ,
@@ -201,13 +201,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ImplVisitor<'a, 'tcx> {
201
201
} ,
202
202
_,
203
203
) => {
204
- if self
205
- . cx
206
- . tcx
207
- . typeck_tables_of ( expr. hir_id . owner . to_def_id ( ) )
208
- . node_type ( expr. hir_id )
209
- == self . self_ty
210
- {
204
+ if expr_ty_matches ( expr, self . self_ty , self . cx ) {
211
205
match ctor_of {
212
206
def:: CtorOf :: Struct => span_lint ( self . cx , path. span ) ,
213
207
def:: CtorOf :: Variant => span_lint_ignore_last_segment ( self . cx , path) ,
0 commit comments