-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #99704 - fee1-dead-contrib:add_self_tilde_const_trait…
…, r=oli-obk Add `Self: ~const Trait` to traits with `#[const_trait]` r? `@oli-obk`
- Loading branch information
Showing
30 changed files
with
199 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,29 @@ | ||
error: overly complex generic constant | ||
--> $DIR/issue-90318.rs:14:8 | ||
error[E0277]: can't compare `TypeId` with `_` in const contexts | ||
--> $DIR/issue-90318.rs:14:28 | ||
| | ||
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True, | ||
| ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| borrowing is not supported in generic constants | ||
| ^^ no implementation for `TypeId == _` | ||
| | ||
= help: consider moving this anonymous constant into a `const` function | ||
= note: this operation may be supported in the future | ||
|
||
error[E0015]: cannot call non-const operator in constants | ||
--> $DIR/issue-90318.rs:14:10 | ||
= help: the trait `~const PartialEq<_>` is not implemented for `TypeId` | ||
note: the trait `PartialEq<_>` is implemented for `TypeId`, but that implementation is not `const` | ||
--> $DIR/issue-90318.rs:14:28 | ||
| | ||
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $SRC_DIR/core/src/any.rs:LL:COL | ||
| | ||
LL | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] | ||
| ^^^^^^^^^ | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
| ^^ | ||
|
||
error: overly complex generic constant | ||
--> $DIR/issue-90318.rs:22:8 | ||
error[E0277]: can't compare `TypeId` with `_` in const contexts | ||
--> $DIR/issue-90318.rs:21:28 | ||
| | ||
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True, | ||
| ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| borrowing is not supported in generic constants | ||
| ^^ no implementation for `TypeId == _` | ||
| | ||
= help: consider moving this anonymous constant into a `const` function | ||
= note: this operation may be supported in the future | ||
|
||
error[E0015]: cannot call non-const operator in constants | ||
--> $DIR/issue-90318.rs:22:10 | ||
= help: the trait `~const PartialEq<_>` is not implemented for `TypeId` | ||
note: the trait `PartialEq<_>` is implemented for `TypeId`, but that implementation is not `const` | ||
--> $DIR/issue-90318.rs:21:28 | ||
| | ||
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $SRC_DIR/core/src/any.rs:LL:COL | ||
| | ||
LL | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] | ||
| ^^^^^^^^^ | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
| ^^ | ||
|
||
error: aborting due to 4 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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
fn main() {} | ||
|
||
// unconst and bad, will thus error in miri | ||
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR cannot be reliably | ||
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR can't compare | ||
// unconst and bad, will thus error in miri | ||
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR cannot be reliably | ||
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR can't compare |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,49 @@ | ||
error: pointers cannot be reliably compared during const eval | ||
--> $DIR/const_raw_ptr_ops.rs:4:26 | ||
error[E0277]: can't compare `*const i32` with `_` in const contexts | ||
--> $DIR/const_raw_ptr_ops.rs:4:43 | ||
| | ||
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^ no implementation for `*const i32 == _` | ||
| | ||
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information | ||
= help: the trait `~const PartialEq<_>` is not implemented for `*const i32` | ||
note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const` | ||
--> $DIR/const_raw_ptr_ops.rs:4:43 | ||
| | ||
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; | ||
| ^^ | ||
= help: the following other types implement trait `PartialEq<Rhs>`: | ||
f32 | ||
f64 | ||
i128 | ||
i16 | ||
i32 | ||
i64 | ||
i8 | ||
isize | ||
and 6 others | ||
|
||
error: pointers cannot be reliably compared during const eval | ||
--> $DIR/const_raw_ptr_ops.rs:6:27 | ||
error[E0277]: can't compare `*const i32` with `_` in const contexts | ||
--> $DIR/const_raw_ptr_ops.rs:6:44 | ||
| | ||
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^ no implementation for `*const i32 == _` | ||
| | ||
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information | ||
= help: the trait `~const PartialEq<_>` is not implemented for `*const i32` | ||
note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const` | ||
--> $DIR/const_raw_ptr_ops.rs:6:44 | ||
| | ||
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; | ||
| ^^ | ||
= help: the following other types implement trait `PartialEq<Rhs>`: | ||
f32 | ||
f64 | ||
i128 | ||
i16 | ||
i32 | ||
i64 | ||
i8 | ||
isize | ||
and 6 others | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
fn id<T>(t: T) -> T { t } | ||
fn main() { | ||
const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () }; | ||
//~^ ERROR pointers cannot be reliably compared during const eval | ||
//~^ ERROR can't compare | ||
println!("{}", A); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
error: pointers cannot be reliably compared during const eval | ||
--> $DIR/issue-25826.rs:3:30 | ||
error[E0277]: can't compare `*const ()` with `*const ()` in const contexts | ||
--> $DIR/issue-25826.rs:3:52 | ||
| | ||
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^ no implementation for `*const () < *const ()` and `*const () > *const ()` | ||
| | ||
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information | ||
= help: the trait `~const PartialOrd` is not implemented for `*const ()` | ||
note: the trait `PartialOrd` is implemented for `*const ()`, but that implementation is not `const` | ||
--> $DIR/issue-25826.rs:3:52 | ||
| | ||
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () }; | ||
| ^ | ||
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | ||
| | ||
LL | fn main() where *const (): ~const PartialOrd { | ||
| ++++++++++++++++++++++++++++++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
const fn cmp(x: fn(), y: fn()) -> bool { | ||
unsafe { x == y } | ||
//~^ ERROR pointers cannot be reliably compared | ||
//~^ ERROR can't compare | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
error: pointers cannot be reliably compared during const eval | ||
--> $DIR/cmp_fn_pointers.rs:2:14 | ||
error[E0277]: can't compare `fn()` with `_` in const contexts | ||
--> $DIR/cmp_fn_pointers.rs:2:16 | ||
| | ||
LL | unsafe { x == y } | ||
| ^^^^^^ | ||
| ^^ no implementation for `fn() == _` | ||
| | ||
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information | ||
= help: the trait `~const PartialEq<_>` is not implemented for `fn()` | ||
note: the trait `PartialEq<_>` is implemented for `fn()`, but that implementation is not `const` | ||
--> $DIR/cmp_fn_pointers.rs:2:16 | ||
| | ||
LL | unsafe { x == y } | ||
| ^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.