-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Make PartialEq
a const_trait
#142822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make PartialEq
a const_trait
#142822
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,15 @@ | ||
error[E0015]: cannot call non-const operator in constants | ||
error[E0277]: the trait bound `TypeId: const PartialEq` is not satisfied | ||
--> $DIR/const_cmp_type_id.rs:8:17 | ||
| | ||
LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $SRC_DIR/core/src/any.rs:LL:COL | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
|
||
error[E0015]: cannot call non-const operator in constants | ||
error[E0277]: the trait bound `TypeId: const PartialEq` is not satisfied | ||
--> $DIR/const_cmp_type_id.rs:10:17 | ||
| | ||
LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $SRC_DIR/core/src/any.rs:LL:COL | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
|
||
error[E0015]: cannot call non-const operator in constants | ||
--> $DIR/const_cmp_type_id.rs:12:18 | ||
| | ||
LL | let _a = TypeId::of::<u8>() < TypeId::of::<u16>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $SRC_DIR/core/src/any.rs:LL:COL | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0277`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
error[E0015]: cannot call non-const operator in constant functions | ||
error[E0277]: the trait bound `TypeId: ~const PartialEq` is not satisfied | ||
--> $DIR/issue-73976-monomorphic.rs:21:5 | ||
| | ||
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $SRC_DIR/core/src/any.rs:LL:COL | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0277`. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is no longer testing the issue - can we change this to another one that still shows the errors? or just remove this test completely (or just have const_trait_impl removed in this test) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also means rust/compiler/rustc_const_eval/src/check_consts/ops.rs Lines 281 to 316 in 9972ebf
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,81 @@ | ||
error[E0015]: cannot call non-const operator in constant functions | ||
--> $DIR/issue-90870.rs:6:5 | ||
error[E0658]: cannot call conditionally-const operator in constant functions | ||
--> $DIR/issue-90870.rs:9:5 | ||
| | ||
LL | a == b | ||
| ^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information | ||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
help: consider dereferencing here | ||
| | ||
LL | *a == *b | ||
| + + | ||
|
||
error[E0015]: cannot call non-const operator in constant functions | ||
--> $DIR/issue-90870.rs:12:5 | ||
error: `PartialEq` is not yet stable as a const trait | ||
--> $DIR/issue-90870.rs:9:5 | ||
| | ||
LL | a == b | ||
| ^^^^^^ | ||
| | ||
help: add `#![feature(const_trait_impl)]` to the crate attributes to enable | ||
| | ||
LL + #![feature(const_trait_impl)] | ||
| | ||
|
||
error[E0658]: cannot call conditionally-const operator in constant functions | ||
--> $DIR/issue-90870.rs:17:5 | ||
| | ||
LL | a == b | ||
| ^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information | ||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
help: consider dereferencing here | ||
| | ||
LL | ****a == ****b | ||
| ++++ ++++ | ||
|
||
error[E0015]: cannot call non-const operator in constant functions | ||
--> $DIR/issue-90870.rs:19:12 | ||
error: `PartialEq` is not yet stable as a const trait | ||
--> $DIR/issue-90870.rs:17:5 | ||
| | ||
LL | a == b | ||
| ^^^^^^ | ||
| | ||
help: add `#![feature(const_trait_impl)]` to the crate attributes to enable | ||
| | ||
LL + #![feature(const_trait_impl)] | ||
| | ||
|
||
error[E0658]: cannot call conditionally-const operator in constant functions | ||
--> $DIR/issue-90870.rs:26:12 | ||
| | ||
LL | if l == r { | ||
| ^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information | ||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
help: consider dereferencing here | ||
| | ||
LL | if *l == *r { | ||
| + + | ||
|
||
error: aborting due to 3 previous errors | ||
error: `PartialEq` is not yet stable as a const trait | ||
--> $DIR/issue-90870.rs:26:12 | ||
| | ||
LL | if l == r { | ||
| ^^^^^^ | ||
| | ||
help: add `#![feature(const_trait_impl)]` to the crate attributes to enable | ||
| | ||
LL + #![feature(const_trait_impl)] | ||
| | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0658`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
//@ known-bug: #110395 | ||
|
||
#![feature(const_trait_impl, const_ops)] | ||
//@ check-pass | ||
|
||
struct Int(i32); | ||
|
||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this library trait guarded by a language feature and its tracking issue?
It doesn't even match the attribute on the impls, which is quite confusing (I think the impl attributes are completely ignored then?)