11use clippy_utils:: diagnostics:: span_lint_and_sugg;
22use clippy_utils:: source:: snippet_with_context;
3- use clippy_utils:: std_or_core;
43use rustc_errors:: Applicability ;
54use rustc_hir:: { BorrowKind , Expr , ExprKind , Mutability , Ty , TyKind } ;
65use rustc_lint:: LateContext ;
@@ -16,11 +15,10 @@ pub(super) fn check<'tcx>(
1615) {
1716 if matches ! ( cast_to. kind, TyKind :: Ptr ( _) )
1817 && let ExprKind :: AddrOf ( BorrowKind :: Ref , mutability, e) = cast_expr. kind
19- && let Some ( std_or_core) = std_or_core ( cx)
2018 {
21- let macro_name = match mutability {
22- Mutability :: Not => "addr_of " ,
23- Mutability :: Mut => "addr_of_mut " ,
19+ let operator_kind = match mutability {
20+ Mutability :: Not => "const " ,
21+ Mutability :: Mut => "mut " ,
2422 } ;
2523 let mut app = Applicability :: MachineApplicable ;
2624 let snip = snippet_with_context ( cx, e. span , cast_expr. span . ctxt ( ) , ".." , & mut app) . 0 ;
@@ -40,7 +38,7 @@ pub(super) fn check<'tcx>(
4038 expr. span ,
4139 "borrow as raw pointer" ,
4240 "try" ,
43- format ! ( "{std_or_core}::ptr::{macro_name}!({ snip}) " ) ,
41+ format ! ( "&raw {operator_kind} { snip}" ) ,
4442 Applicability :: MachineApplicable ,
4543 ) ;
4644 }
0 commit comments