-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed as not planned
Closed as not planned
Copy link
Labels
C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
It can be surprising that debug_assert_eq
still requires the type implement PartialEq
in release mode.
I tried this code:
fn main() {
let one = Thing;
let two = Thing;
debug_assert_eq!(one, two);
}
#[derive(Debug)]
#[cfg_attr(debug_assertions, derive(PartialEq))]
struct Thing;
I expected to see this happen: The debug_assert_eq
macro would not require PartialEq
when debug_assertions
is not enabled (i.e. release mode).
Instead, this happened: In release mode, debug_assert_eq
was expanded in such a way that PartialEq
is still required to be implemented, even though it's never executed.
Meta
rustc --version --verbose
:
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: aarch64-apple-darwin
release: 1.89.0
LLVM version: 20.1.7
As well as in the playground on stable (1.90.0
), 1.91.0-beta.4 (2025-09-27 aa7859c0dec2de6c9cab)
, and 1.92.0-nightly (2025-09-30 fa3155a644dd62e86582)
.
Metadata
Metadata
Assignees
Labels
C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.