@@ -76,12 +76,10 @@ fn is_path_self(e: &Expr<'_>) -> bool {
76
76
}
77
77
}
78
78
79
- fn contains_trait_object ( cx : & LateContext < ' _ > , ty : ty:: Ty < ' _ > ) -> bool {
79
+ fn contains_trait_object ( ty : ty:: Ty < ' _ > ) -> bool {
80
80
match ty. kind ( ) {
81
- ty:: TyKind :: Ref ( _, ty, _) => contains_trait_object ( cx, * ty) ,
82
- ty:: TyKind :: Adt ( def, substs) => {
83
- def. is_box ( ) && substs[ 0 ] . as_type ( ) . map_or ( false , |ty| contains_trait_object ( cx, ty) )
84
- } ,
81
+ ty:: TyKind :: Ref ( _, ty, _) => contains_trait_object ( * ty) ,
82
+ ty:: TyKind :: Adt ( def, substs) => def. is_box ( ) && substs[ 0 ] . as_type ( ) . map_or ( false , contains_trait_object) ,
85
83
ty:: TyKind :: Dynamic ( ..) => true ,
86
84
_ => false ,
87
85
}
@@ -118,13 +116,13 @@ fn check_struct<'tcx>(
118
116
is_default_equivalent ( cx, expr)
119
117
&& typeck_results. expr_adjustments ( expr) . iter ( ) . all ( |adj| {
120
118
!matches ! ( adj. kind, Adjust :: Pointer ( PointerCast :: Unsize )
121
- if contains_trait_object( cx , adj. target) )
119
+ if contains_trait_object( adj. target) )
122
120
} )
123
121
} ;
124
122
125
123
let should_emit = match peel_blocks ( func_expr) . kind {
126
- ExprKind :: Tup ( fields) => fields. iter ( ) . all ( |e| is_default_without_adjusts ( e ) ) ,
127
- ExprKind :: Call ( callee, args) if is_path_self ( callee) => args. iter ( ) . all ( |e| is_default_without_adjusts ( e ) ) ,
124
+ ExprKind :: Tup ( fields) => fields. iter ( ) . all ( is_default_without_adjusts) ,
125
+ ExprKind :: Call ( callee, args) if is_path_self ( callee) => args. iter ( ) . all ( is_default_without_adjusts) ,
128
126
ExprKind :: Struct ( _, fields, _) => fields. iter ( ) . all ( |ef| is_default_without_adjusts ( ef. expr ) ) ,
129
127
_ => false ,
130
128
} ;
0 commit comments