about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorsurechen <chenshuo17@huawei.com>2024-11-12 10:17:41 +0800
committersurechen <chenshuo17@huawei.com>2024-11-12 10:17:41 +0800
commit33d3c27d38df5af198ecb9ace7546cab37818dc5 (patch)
treef5af8e514eb44a8969eb8bac8380b4b2f3c31573 /compiler
parent3a258d1cf9d52831820c223018fd74b208b5c65a (diff)
downloadrust-33d3c27d38df5af198ecb9ace7546cab37818dc5.tar.gz
rust-33d3c27d38df5af198ecb9ace7546cab37818dc5.zip
For expr `return (_ = 42);` unused_paren lint should not be triggered
fixes #131989
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_lint/src/unused.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs
index b50a95e7d2b..52126afcf5a 100644
--- a/compiler/rustc_lint/src/unused.rs
+++ b/compiler/rustc_lint/src/unused.rs
@@ -1063,6 +1063,8 @@ impl UnusedDelimLint for UnusedParens {
                                 _,
                                 _,
                             ) if node.is_lazy()))
+                    && !(ctx == UnusedDelimsCtx::ReturnValue
+                        && matches!(inner.kind, ast::ExprKind::Assign(_, _, _)))
                 {
                     self.emit_unused_delims_expr(cx, value, ctx, left_pos, right_pos, is_kw)
                 }