-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-const_trait_impl`#![feature(const_trait_impl)]``#![feature(const_trait_impl)]`PG-const-traitsProject group: Const traitsProject group: Const traitsT-langRelevant to the language teamRelevant to the language team
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
hudson-ayers, DominicBurkart and IndigoLily
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-const_trait_impl`#![feature(const_trait_impl)]``#![feature(const_trait_impl)]`PG-const-traitsProject group: Const traitsProject group: Const traitsT-langRelevant to the language teamRelevant to the language team