-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Constify PartialEq
#133995
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
base: master
Are you sure you want to change the base?
Constify PartialEq
#133995
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,17 +1,15 @@ | ||
//@ compile-flags: -Znext-solver | ||
|
||
#![feature(const_type_id, const_trait_impl)] | ||
|
||
use std::any::TypeId; | ||
|
||
fn main() { | ||
const { | ||
assert!(TypeId::of::<u8>() == TypeId::of::<u8>()); | ||
//~^ ERROR cannot call non-const operator in constants | ||
//~^ ERROR the trait bound `TypeId: const PartialEq` is not satisfied | ||
assert!(TypeId::of::<()>() != TypeId::of::<u8>()); | ||
//~^ ERROR cannot call non-const operator in constants | ||
//~^ ERROR the trait bound `TypeId: const PartialEq` is not satisfied | ||
let _a = TypeId::of::<u8>() < TypeId::of::<u16>(); | ||
//~^ ERROR cannot call non-const operator in constants | ||
// can't assert `_a` because it is not deterministic | ||
// FIXME(const_trait_impl) make it pass | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,15 @@ | ||
error[E0015]: cannot call non-const operator in constants | ||
--> $DIR/const_cmp_type_id.rs:8:17 | ||
error[E0277]: the trait bound `TypeId: const PartialEq` is not satisfied | ||
--> $DIR/const_cmp_type_id.rs:9: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 | ||
--> $DIR/const_cmp_type_id.rs:10:17 | ||
error[E0277]: the trait bound `TypeId: const PartialEq` is not satisfied | ||
--> $DIR/const_cmp_type_id.rs:11: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 | ||
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
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`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,33 @@ | ||
error[E0015]: cannot call non-const operator in constant functions | ||
error[E0658]: cannot call conditionally-const method `<&u8 as PartialEq>::eq` in constant functions | ||
--> $DIR/issue-90870.rs:6:5 | ||
| | ||
LL | a == b | ||
| ^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
help: consider dereferencing here | ||
| | ||
LL | *a == *b | ||
| + + | ||
= 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 | ||
|
||
error[E0015]: cannot call non-const operator in constant functions | ||
--> $DIR/issue-90870.rs:12:5 | ||
error[E0658]: cannot call conditionally-const method `<&&&&i64 as PartialEq>::eq` in constant functions | ||
--> $DIR/issue-90870.rs:11:5 | ||
| | ||
LL | a == b | ||
| ^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
help: consider dereferencing here | ||
| | ||
LL | ****a == ****b | ||
| ++++ ++++ | ||
= 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 | ||
|
||
error[E0015]: cannot call non-const operator in constant functions | ||
--> $DIR/issue-90870.rs:19:12 | ||
error[E0658]: cannot call conditionally-const method `<&u8 as PartialEq>::eq` in constant functions | ||
--> $DIR/issue-90870.rs:17:12 | ||
| | ||
LL | if l == r { | ||
| ^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
help: consider dereferencing here | ||
| | ||
LL | if *l == *r { | ||
| + + | ||
= 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 | ||
|
||
error: aborting due to 3 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,4 +1,4 @@ | ||
//@ known-bug: #110395 | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl)] | ||
|
||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
//@ compile-flags: -Znext-solver | ||
#![feature(const_trait_impl)] | ||
|
||
pub const fn equals_self<T: PartialEq>(t: &T) -> bool { | ||
*t == *t | ||
//~^ ERROR cannot call non-const operator in constant functions | ||
//~^ ERROR the trait bound `T: ~const PartialEq` is not satisfied | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
error[E0015]: cannot call non-const operator in constant functions | ||
--> $DIR/call-generic-method-fail.rs:5:5 | ||
error[E0277]: the trait bound `T: ~const PartialEq` is not satisfied | ||
--> $DIR/call-generic-method-fail.rs:4:5 | ||
| | ||
LL | *t == *t | ||
| ^^^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
help: consider further restricting this bound | ||
| | ||
LL | pub const fn equals_self<T: PartialEq + ~const std::cmp::PartialEq>(t: &T) -> bool { | ||
| ++++++++++++++++++++++++++++ | ||
|
||
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`. |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
error[E0015]: cannot match on `str` in constant functions | ||
--> $DIR/match-non-const-eq.rs:7:9 | ||
error[E0658]: cannot call conditionally-const method `<str as PartialEq>::eq` in constant functions | ||
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. Nitpick: surprised that when rendering predicates we talk about 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. well, so, 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. like, 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 somewhat related to the fact that we allow users to write |
||
--> $DIR/match-non-const-eq.rs:8:9 | ||
| | ||
LL | "a" => (), //FIXME [gated]~ ERROR can't compare `str` with `str` in const contexts | ||
LL | "a" => (), | ||
| ^^^ | ||
| | ||
= note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es | ||
= 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 | ||
|
||
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 E0658`. |
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.
The tracking issue #101871 has never been updated >.< It didn't track the unconstification.