about summary refs log tree commit diff
path: root/clippy_lints/src/reference.rs
diff options
context:
space:
mode:
authorLzu Tao <taolzu@gmail.com>2024-05-29 09:19:33 +0700
committerLzu Tao <taolzu@gmail.com>2024-05-30 08:34:44 +0700
commit8bd2a17dfe1b5089b942c44db6b152f5d4b30a3e (patch)
treeb1f09d0f063994fc8e64d57424424457eb66f894 /clippy_lints/src/reference.rs
parent4dcab72c1c796c51afb3f68c554b22e7ff222a64 (diff)
ignore array from `deref_addrof` lint
Note that semantics of repeat expr in array are the same
Diffstat (limited to 'clippy_lints/src/reference.rs')
-rw-r--r--clippy_lints/src/reference.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs
index 16086ba6637..8f32cf5f2a1 100644
--- a/clippy_lints/src/reference.rs
+++ b/clippy_lints/src/reference.rs
@@ -48,6 +48,9 @@ impl EarlyLintPass for DerefAddrOf {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
         if let ExprKind::Unary(UnOp::Deref, ref deref_target) = e.kind
             && let ExprKind::AddrOf(_, ref mutability, ref addrof_target) = without_parens(deref_target).kind
+            // NOTE(tesuji): `*&` forces rustc to const-promote the array to `.rodata` section.
+            // See #12854 for details.
+            && !matches!(addrof_target.kind, ExprKind::Array(_))
             && deref_target.span.eq_ctxt(e.span)
             && !addrof_target.span.from_expansion()
         {