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
Diagnostics: Suggest replacing (problematic) assert!(x, y) with assert_eq!(x, y) #57507
error[E0308]: mismatched types
--> src/main.rs:3:5
|
3 | assert!(x, 3);
| ^^^^^^^^^^^^^^ expected bool, found integer
|
= note: expected type `bool`
found type `{integer}`
error: aborting due to previous error
If arguments 1 and 2 are the same type, it would be great if we could instead suggest using assert_eq! instead (preferably with rustfix applicable hint)!
Alternatively we could suggest transforming x, 3 to x == 3 but I guess assert_eq!() is more idiomatic.
changed the title [-]diagnostics: suggets assert_eq!() instead of assert!() where appropriate[/-][+]Diagnostics: Suggest `assert_eq!(x, y)` for bad `assert!(x, y)`[/+]on Jul 24, 2025
changed the title [-]Diagnostics: Suggest `assert_eq!(x, y)` for bad `assert!(x, y)`[/-][+]Diagnostics: Suggest replacing (problematic) `assert!(x, y)` with `assert_eq!(x, y)`[/+]on Jul 24, 2025
Activity
[-]diagnostics: suggets assert_eq!() instead of assert!() where appropriate[/-][+]Diagnostics: Suggest `assert_eq!(x, y)` for bad `assert!(x, y)`[/+][-]Diagnostics: Suggest `assert_eq!(x, y)` for bad `assert!(x, y)`[/-][+]Diagnostics: Suggest replacing (problematic) `assert!(x, y)` with `assert_eq!(x, y)`[/+]bend-n commentedon Jul 25, 2025
with #44838, would it be better to suggest
x == 3?estebank commentedon Aug 5, 2025
CC #122661, as it might require the approach to detect this case to be different.
assert_eq!mistyped asassert!#148476 as a duplicate of this issue