You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suboptimal diagnostic for assert_eq! mistyped as assert! #148476
error: format argument must be a string literal
--> src/lib.rs:5:16
|
5 | assert!(a, b);| ^
|
help: you might be missing a string literal to format with
|
5 | assert!(a, "{}", b);| +++++
error[E0308]: mismatched types
--> src/lib.rs:5:5
|
5 | assert!(a, b);| ^^^^^^^^^^^^^ expected `bool`, found `i32`
Desired output
error: format argument must be a string literal
--> src/lib.rs:5:16
|
5 | assert!(a, b);| ^
|
help: you might have meant to use `assert_eq!`|
5 | assert_eq!(a, b);| +++
error[E0308]: mismatched types
--> src/lib.rs:5:5
|
5 | assert!(a, b);| ^^^^^^^^^^^^^ expected `bool`, found `i32`
Rationale and extra context
When the two arguments have the same types (that is not bool), it's imo more likely that the user meant to use assert_eq!. In my case, this happened when I wanted to change an assert! to assert_eq!, but only replaced == with ,, forgetting to change the name as well.
Activity
fmease commentedon Nov 5, 2025
cc #57507
ada4a commentedon Nov 5, 2025
Looks like a complete duplicate... Sorry, I did try to search through existing issues, but it's a bit hard with keywords like this
assert!(x, y)withassert_eq!(x, y)#57507