@@ -12,7 +12,7 @@ pub fn maybe_expr_static_mut(tcx: TyCtxt<'_>, expr: hir::Expr<'_>) {
1212 let hir_id = expr. hir_id ;
1313 if let hir:: ExprKind :: AddrOf ( borrow_kind, m, expr) = expr. kind
1414 && matches ! ( borrow_kind, hir:: BorrowKind :: Ref )
15- && let Some ( var) = is_path_static_mut ( * expr)
15+ && let Some ( var) = path_if_static_mut ( tcx , expr)
1616 {
1717 handle_static_mut_ref ( tcx, span, var, span. edition ( ) . at_least_rust_2024 ( ) , m, hir_id) ;
1818 }
@@ -24,7 +24,7 @@ pub fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
2424 && let hir:: PatKind :: Binding ( ba, _, _, _) = loc. pat . kind
2525 && let hir:: ByRef :: Yes ( rmutbl) = ba. 0
2626 && let Some ( init) = loc. init
27- && let Some ( var) = is_path_static_mut ( * init)
27+ && let Some ( var) = path_if_static_mut ( tcx , init)
2828 {
2929 handle_static_mut_ref (
3030 tcx,
@@ -37,13 +37,13 @@ pub fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
3737 }
3838}
3939
40- fn is_path_static_mut ( expr : hir:: Expr < ' _ > ) -> Option < String > {
40+ fn path_if_static_mut ( tcx : TyCtxt < ' _ > , expr : & hir:: Expr < ' _ > ) -> Option < String > {
4141 if let hir:: ExprKind :: Path ( qpath) = expr. kind
4242 && let hir:: QPath :: Resolved ( _, path) = qpath
4343 && let hir:: def:: Res :: Def ( def_kind, _) = path. res
4444 && let hir:: def:: DefKind :: Static { mutability : Mutability :: Mut , nested : false } = def_kind
4545 {
46- return Some ( qpath_to_string ( & qpath) ) ;
46+ return Some ( qpath_to_string ( & tcx , & qpath) ) ;
4747 }
4848 None
4949}
0 commit comments