@@ -20,6 +20,16 @@ pub(super) fn check(
2020 is_mut : bool ,
2121 msrv : & Msrv ,
2222) {
23+ static DEREF_ALIASES : [ & [ & str ] ; 7 ] = [
24+ & paths:: CSTRING_AS_C_STR ,
25+ & paths:: OS_STRING_AS_OS_STR ,
26+ & paths:: PATH_BUF_AS_PATH ,
27+ & paths:: STRING_AS_STR ,
28+ & paths:: STRING_AS_MUT_STR ,
29+ & paths:: VEC_AS_SLICE ,
30+ & paths:: VEC_AS_MUT_SLICE ,
31+ ] ;
32+
2333 if !msrv. meets ( msrvs:: OPTION_AS_DEREF ) {
2434 return ;
2535 }
@@ -31,24 +41,14 @@ pub(super) fn check(
3141 return ;
3242 }
3343
34- let deref_aliases: [ & [ & str ] ; 7 ] = [
35- & paths:: CSTRING_AS_C_STR ,
36- & paths:: OS_STRING_AS_OS_STR ,
37- & paths:: PATH_BUF_AS_PATH ,
38- & paths:: STRING_AS_STR ,
39- & paths:: STRING_AS_MUT_STR ,
40- & paths:: VEC_AS_SLICE ,
41- & paths:: VEC_AS_MUT_SLICE ,
42- ] ;
43-
4444 let is_deref = match map_arg. kind {
4545 hir:: ExprKind :: Path ( ref expr_qpath) => {
4646 cx. qpath_res ( expr_qpath, map_arg. hir_id )
4747 . opt_def_id ( )
4848 . map_or ( false , |fun_def_id| {
4949 cx. tcx . is_diagnostic_item ( sym:: deref_method, fun_def_id)
5050 || cx. tcx . is_diagnostic_item ( sym:: deref_mut_method, fun_def_id)
51- || deref_aliases . iter ( ) . any ( |path| match_def_path ( cx, fun_def_id, path) )
51+ || DEREF_ALIASES . iter ( ) . any ( |path| match_def_path ( cx, fun_def_id, path) )
5252 } )
5353 } ,
5454 hir:: ExprKind :: Closure ( & hir:: Closure { body, .. } ) => {
@@ -69,7 +69,7 @@ pub(super) fn check(
6969 let method_did = cx. typeck_results ( ) . type_dependent_def_id ( closure_expr. hir_id ) . unwrap ( ) ;
7070 cx. tcx . is_diagnostic_item ( sym:: deref_method, method_did)
7171 || cx. tcx . is_diagnostic_item ( sym:: deref_mut_method, method_did)
72- || deref_aliases . iter ( ) . any ( |path| match_def_path ( cx, method_did, path) )
72+ || DEREF_ALIASES . iter ( ) . any ( |path| match_def_path ( cx, method_did, path) )
7373 } else {
7474 false
7575 }
0 commit comments