Closed
Description
The derived PartialEq implementation cannot be used in a const
context.
The code below gives error E0015
#[derive(PartialEq)]
struct A(u8);
const fn is_eq(left: &A, right: &A) -> bool {
left == right
}
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> derive_eq_partialeq.rs:5:2
|
5 | left == right
| ^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0015`.
Meta
rustc --version --verbose
:
rustc 1.49.0-nightly (91a79fb29 2020-10-07)
binary: rustc
commit-hash: 91a79fb29ac78d057d04dbe86be13d5dcc64309a
commit-date: 2020-10-07
host: x86_64-pc-windows-msvc
release: 1.49.0-nightly
LLVM version: 11.0