- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Open
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.F-contracts`#![feature(contracts)]``#![feature(contracts)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Using the following flags
--force-warn unused_parens
this code:
#![feature(contracts)]
#[core::contracts::requires(x.baz > 0)]
#[core::contracts::ensures(|ret| *ret > 100)]
fn nest(x: Baz) -> i32
{
    loop {
        return x.baz + 50;
    }
}
struct Baz { baz: i32 }
fn main() {}caused the following diagnostics:
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Checking _a v0.1.0 (/tmp/icemaker_global_tempdir.mjalOFICDlk5/icemaker_clippyfix_tempdir.rnyxLGd0A92q/_a)
warning: unnecessary parentheses around closure body
 --> src/main.rs:3:1
  |
3 | #[core::contracts::requires(x.baz > 0)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^         ^^
  |
  = note: requested on the command line with `--force-warn unused-parens`
help: remove these parentheses
  |
3 - #[core::contracts::requires(x.baz > 0)]
3 + x.baz > 0
  |
warning: `_a` (bin "_a") generated 1 warning (run `cargo clippy --fix --bin "_a"` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.36s
However after applying these diagnostics, the resulting code:
#![feature(contracts)]
x.baz > 0
#[core::contracts::ensures(|ret| *ret > 100)]
fn nest(x: Baz) -> i32
{
    loop {
        return x.baz + 50;
    }
}
struct Baz { baz: i32 }
fn main() {}no longer compiled:
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Checking _a v0.1.0 (/tmp/icemaker_global_tempdir.mjalOFICDlk5/icemaker_clippyfix_tempdir.rnyxLGd0A92q/_a)
error: expected one of `!` or `::`, found `.`
 --> src/main.rs:3:2
  |
3 | x.baz > 0
  |  ^ expected one of `!` or `::`
error: could not compile `_a` (bin "_a" test) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_a` (bin "_a") due to 1 previous error
Version:
rustc 1.90.0-nightly (78a6e1329 2025-07-10)
binary: rustc
commit-hash: 78a6e132984dba0303ebad7dcfd1305c93ad5835
commit-date: 2025-07-10
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.F-contracts`#![feature(contracts)]``#![feature(contracts)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.