Skip to content

unused_braces warning emitted for braces that have semantic value #154247

Closed

Description

@cartercanedy

Summary

Since the adoption of tail expression temporary scope changes in the 2024 edition, it is safe to wrap a method call on a temporary lock guard in a block with assurance that the lock will be dropped before exiting the scope. It seems like this lint is either being emitted in error (false positive) or the other, very similar expression in the same file is not being detected (false negative).

Lint Name

unused_braces

Reproducer

Diagnostic emitted by rustc:

warning: unnecessary braces around method argument
   --> .../file.rs:459:29
    |
459 |         self.update({ self.lockable.lock().do_work()?.collect() })
    |                     ^^                                         ^^
    |
    = note: `#[warn(unused_braces)]` on by default
help: remove these braces
    |
459 -         self.update({ self.lockable.lock().do_work()?.collect() })
459 +         self.update(self.lockable.lock().do_work()?.collect())

There's a similar implementation in an impl block right below this that does not have this lint emitted

Version

rustc 1.96.0-nightly (562dee482 2026-03-21)
binary: rustc
commit-hash: 562dee4820c458d823175268e41601d4c060588a
commit-date: 2026-03-21
host: aarch64-apple-darwin
release: 1.96.0-nightly
LLVM version: 22.1.0

Additional Labels

No response

Activity

  1. samueltardieu commented on Mar 23, 2026

    @samueltardieu
    Member

    unused_braces is a lint emitted by the compiler, not Clippy (Clippy lints are prefixed with clippy::). You are likely encountering the same warning when running cargo check or cargo build.

    @rustbot transfer rust

  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 23, 2026
  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    L-false-positiveLint: False positive (should not have fired).
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 31, 2026
  4. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    on Apr 15, 2026
  5. added 2 commits that reference this issue on Jul 28, 2026
    bd65482
    f20c697
  6. added 3 commits that reference this issue on Sep 11, 2026
    7a8219f
    e0c04b1
    04b9547
  7. added a commit that references this issue on Sep 11, 2026
    4c0ae0b
  8. added a commit that references this issue on Sep 11, 2026
    00df995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.L-false-positiveLint: False positive (should not have fired).L-unused_bracesLint: unused_bracesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions