Unnecessary parentheses warnings with odd spans since 1.90
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
# Cargo.toml
[package]
name = "repro"
version = "0.1.0"
edition = "2024"
[dependencies]
scryer-modular-bitfield = "0.11.4"
[lints.rust]
unused_parens = "deny"
// src/lib.rs
use scryer_modular_bitfield::bitfield;
use scryer_modular_bitfield::specifiers::*;
#[bitfield]
#[repr(u64)]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct UntypedArenaPtr {
#[allow(unused)]
ptr: B61,
m: bool,
#[allow(unused)]
padding: B2,
}
pub fn test() {
dbg!(UntypedArenaPtr::new());
}
Current output
$ cargo +1.90 check
Checking repro v0.1.0 (/home/bennet/git/tmp/repro)
error: unnecessary parentheses around type
--> src/lib.rs:10:5
|
10 | #[allow(unused)]
| ^ help: remove these parentheses
|
= note: requested on the command line with `-D unused-parens`
error: unnecessary parentheses around type
--> src/lib.rs:12:5
|
12 | m: bool,
| ^ help: remove these parentheses
error: unnecessary parentheses around type
--> src/lib.rs:13:5
|
13 | #[allow(unused)]
| ^ help: remove these parentheses
warning: method `m` is never used
--> src/lib.rs:12:5
|
7 | #[repr(u64)]
| - method in this implementation
...
12 | m: bool,
| ^
|
= note: `#[warn(dead_code)]` on by default
warning: `repro` (lib) generated 1 warning
error: could not compile `repro` (lib) due to 3 previous errors; 1 warning emitted
Desired output
$ cargo +1.89 check
Checking repro v0.1.0 (/home/bennet/git/tmp/repro)
warning: method `m` is never used
--> src/lib.rs:12:5
|
7 | #[repr(u64)]
| - method in this implementation
...
12 | m: bool,
| ^
|
= note: `#[warn(dead_code)]` on by default
warning: `repro` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.60s
Rationale and extra context
It's rather of seeing a diagnostic for unnecessary parentheses that is pointing nowhere near parenthesis. Also as the offending code is suspected to be macro generated fixing it is non-actionable for the user and as such the diagnostic is confusing.
The involved types all use the #[bitfield] attribute macro, so I suspect it is generating code with unnecessary parenthesis and for some reason they weren't reported prior to 1.90 and for some reason starting with 1.90 they are now reported with odd spans.
Rust Version
$ rustc +1.90 --version --verbose
rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: x86_64-unknown-linux-gnu
release: 1.90.0
LLVM version: 20.1.8
Anything else?
This was reported to the scryer-prolog project in mthom/scryer-prolog#3092
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with Cargo.toml and src/lib.rs using cargo +1.90 check, then compare the diagnostics with cargo +1.89 check. Investigate the unused_parens diagnostic handling for the #[bitfield] macro-generated types and their spans. Done means the compiler no longer reports misleading unnecessary-parentheses diagnostics at unrelated source locations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100