Skip to content

Commit 33d3c27

Browse files
committed
For expr return (_ = 42); unused_paren lint should not be triggered
fixes #131989
1 parent 3a258d1 commit 33d3c27

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

compiler/rustc_lint/src/unused.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,8 @@ impl UnusedDelimLint for UnusedParens {
10631063
_,
10641064
_,
10651065
) if node.is_lazy()))
1066+
&& !(ctx == UnusedDelimsCtx::ReturnValue
1067+
&& matches!(inner.kind, ast::ExprKind::Assign(_, _, _)))
10661068
{
10671069
self.emit_unused_delims_expr(cx, value, ctx, left_pos, right_pos, is_kw)
10681070
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ check-pass
2+
#![warn(unused_parens)]
3+
4+
fn foo() {
5+
return (_ = 42);
6+
// lint unused_parens should not be triggered here.
7+
}
8+
9+
fn main() {}

0 commit comments

Comments
 (0)