@@ -76,12 +76,13 @@ fn check_arguments<'tcx>(
7676 name : & str ,
7777 fn_kind : & str ,
7878) {
79+ let tcx = cx. tcx ;
7980 // whether `func` is `Path::new`
8081 let is_path_new = |func : & Expr < ' _ > | {
8182 if let ExprKind :: Path ( ref qpath) = func. kind
8283 && let QPath :: TypeRelative ( ty, path) = qpath
8384 && 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)
8586 && path. ident . name == sym:: new
8687 {
8788 true
@@ -90,19 +91,19 @@ fn check_arguments<'tcx>(
9091 }
9192 } ;
9293
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 {
9495 return ;
9596 } ;
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 {
99100 return ;
100101 } ;
101102
102103 let implements_asref_path = |arg| implements_trait ( cx, arg, asref_def_id, & [ path_ty. into ( ) ] ) ;
103104
104105 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 ( ) ;
106107 for ( argument, parameter) in iter:: zip ( arguments, parameters) {
107108 if let ExprKind :: Call ( func, args) = argument. kind
108109 && is_path_new ( func)
0 commit comments