@@ -12,7 +12,7 @@ pub fn maybe_expr_static_mut(tcx: TyCtxt<'_>, expr: hir::Expr<'_>) {
12
12
let hir_id = expr. hir_id ;
13
13
if let hir:: ExprKind :: AddrOf ( borrow_kind, m, expr) = expr. kind
14
14
&& 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)
16
16
{
17
17
handle_static_mut_ref ( tcx, span, var, span. edition ( ) . at_least_rust_2024 ( ) , m, hir_id) ;
18
18
}
@@ -24,7 +24,7 @@ pub fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
24
24
&& let hir:: PatKind :: Binding ( ba, _, _, _) = loc. pat . kind
25
25
&& let hir:: ByRef :: Yes ( rmutbl) = ba. 0
26
26
&& let Some ( init) = loc. init
27
- && let Some ( var) = is_path_static_mut ( * init)
27
+ && let Some ( var) = path_if_static_mut ( tcx , init)
28
28
{
29
29
handle_static_mut_ref (
30
30
tcx,
@@ -37,13 +37,13 @@ pub fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
37
37
}
38
38
}
39
39
40
- fn is_path_static_mut ( expr : hir:: Expr < ' _ > ) -> Option < String > {
40
+ fn path_if_static_mut ( tcx : TyCtxt < ' _ > , expr : & hir:: Expr < ' _ > ) -> Option < String > {
41
41
if let hir:: ExprKind :: Path ( qpath) = expr. kind
42
42
&& let hir:: QPath :: Resolved ( _, path) = qpath
43
43
&& let hir:: def:: Res :: Def ( def_kind, _) = path. res
44
44
&& let hir:: def:: DefKind :: Static { mutability : Mutability :: Mut , nested : false } = def_kind
45
45
{
46
- return Some ( qpath_to_string ( & qpath) ) ;
46
+ return Some ( qpath_to_string ( & tcx , & qpath) ) ;
47
47
}
48
48
None
49
49
}
0 commit comments