@@ -76,12 +76,13 @@ fn check_arguments<'tcx>(
76
76
name : & str ,
77
77
fn_kind : & str ,
78
78
) {
79
+ let tcx = cx. tcx ;
79
80
// whether `func` is `Path::new`
80
81
let is_path_new = |func : & Expr < ' _ > | {
81
82
if let ExprKind :: Path ( ref qpath) = func. kind
82
83
&& let QPath :: TypeRelative ( ty, path) = qpath
83
84
&& let Some ( did) = path_res ( cx, * ty) . opt_def_id ( )
84
- && cx . tcx . is_diagnostic_item ( sym:: Path , did)
85
+ && tcx. is_diagnostic_item ( sym:: Path , did)
85
86
&& path. ident . name == sym:: new
86
87
{
87
88
true
@@ -90,19 +91,19 @@ fn check_arguments<'tcx>(
90
91
}
91
92
} ;
92
93
93
- let Some ( path_def_id) = cx . tcx . get_diagnostic_item ( sym:: Path ) else {
94
+ let Some ( path_def_id) = tcx. get_diagnostic_item ( sym:: Path ) else {
94
95
return ;
95
96
} ;
96
- let path_ty_kind = ty:: Adt ( cx . tcx . adt_def ( path_def_id) , List :: empty ( ) ) ;
97
- let path_ty = cx . tcx . mk_ty_from_kind ( path_ty_kind) ;
98
- let Some ( asref_def_id) = cx . tcx . get_diagnostic_item ( sym:: AsRef ) else {
97
+ let path_ty_kind = ty:: Adt ( tcx. adt_def ( path_def_id) , List :: empty ( ) ) ;
98
+ let path_ty = tcx. mk_ty_from_kind ( path_ty_kind) ;
99
+ let Some ( asref_def_id) = tcx. get_diagnostic_item ( sym:: AsRef ) else {
99
100
return ;
100
101
} ;
101
102
102
103
let implements_asref_path = |arg| implements_trait ( cx, arg, asref_def_id, & [ path_ty. into ( ) ] ) ;
103
104
104
105
if let ty:: FnDef ( ..) | ty:: FnPtr ( ..) = type_definition. kind ( ) {
105
- let parameters = type_definition. fn_sig ( cx . tcx ) . skip_binder ( ) . inputs ( ) ;
106
+ let parameters = type_definition. fn_sig ( tcx) . skip_binder ( ) . inputs ( ) ;
106
107
for ( argument, parameter) in iter:: zip ( arguments, parameters) {
107
108
if let ExprKind :: Call ( func, args) = argument. kind
108
109
&& is_path_new ( func)
0 commit comments