Code
fn main() {
let buf = [0_u8; 4];
assert_ne!(buf, b"----");
}
Current output
error[E0277]: can't compare `[u8; 4]` with `&[u8; 4]`
--> src/main.rs:3:5
|
3 | assert_ne!(buf, b"----");
| ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `[u8; 4] == &[u8; 4]`
|
= help: the trait `PartialEq<&[u8; 4]>` is not implemented for `[u8; 4]`
= note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider dereferencing here
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/macros/mod.rs:102:33
|
10| if *left_val == **right_val {
| +
Desired output
error[E0277]: can't compare `[u8; 4]` with `&[u8; 4]`
--> src/main.rs:3:5
|
3 | assert_ne!(buf, b"----");
| ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `[u8; 4] == &[u8; 4]`
|
= help: the trait `PartialEq<&[u8; 4]>` is not implemented for `[u8; 4]`
= note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider borrowing here
--> src/main.rs:3:16
|
3| assert_ne!(&buf, b"----");
| +
Rationale and extra context
The suggestion of fix should not point into internals of standard library.
Other cases
Rust Version
rustc 1.90.0-nightly (430d6eddf 2025-07-25)
binary: rustc
commit-hash: 430d6eddfc6a455ca4a0137c0822a982cccd3b2b
commit-date: 2025-07-25
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8
Also reproduces on Playground on stable 1.89.0, on beta 1.90.0-beta.7, on nightly 1.91.0-nightly (2025-09-03 a1208bf765ba783ee4eb).
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
The suggestion of fix should not point into internals of standard library.
Other cases
Rust Version
Anything else?
No response