Skip to content

Commit

Permalink
For expr return (_ = 42); unused_paren lint should not be triggered
Browse files Browse the repository at this point in the history
fixes #131989
  • Loading branch information
surechen committed Nov 12, 2024
1 parent 3a258d1 commit 33d3c27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ check-pass
#![warn(unused_parens)]

fn foo() {
return (_ = 42);
// lint unused_parens should not be triggered here.
}

fn main() {}

0 comments on commit 33d3c27

Please sign in to comment.