-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #133926 - compiler-errors:const-conditions, r=lcnr
Fix const conditions for RPITITs Fixes #133918 r? lcnr
- Loading branch information
Showing
5 changed files
with
254 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//@ compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl)] | ||
#![allow(refining_impl_trait)] | ||
|
||
#[const_trait] | ||
pub trait Foo { | ||
fn method(self) -> impl ~const Bar; | ||
} | ||
|
||
#[const_trait] | ||
pub trait Bar {} | ||
|
||
struct A<T>(T); | ||
impl<T> const Foo for A<T> where A<T>: ~const Bar { | ||
fn method(self) -> impl ~const Bar { | ||
self | ||
} | ||
} | ||
|
||
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
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 |
---|---|---|
@@ -0,0 +1,187 @@ | ||
error[E0635]: unknown feature `const_cmp` | ||
--> $DIR/const-impl-trait.rs:7:30 | ||
| | ||
LL | #![feature(const_trait_impl, const_cmp, const_destruct)] | ||
| ^^^^^^^^^ | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:11:23 | ||
| | ||
LL | const fn cmp(a: &impl ~const PartialEq) -> bool { | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:11:23 | ||
| | ||
LL | const fn cmp(a: &impl ~const PartialEq) -> bool { | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:16:13 | ||
| | ||
LL | x: impl ~const PartialEq + ~const Destruct, | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:17:11 | ||
| | ||
LL | ) -> impl ~const PartialEq + ~const Destruct { | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:17:11 | ||
| | ||
LL | ) -> impl ~const PartialEq + ~const Destruct { | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:17:11 | ||
| | ||
LL | ) -> impl ~const PartialEq + ~const Destruct { | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:16:13 | ||
| | ||
LL | x: impl ~const PartialEq + ~const Destruct, | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:23:22 | ||
| | ||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:27:22 | ||
| | ||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:27:22 | ||
| | ||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:23:22 | ||
| | ||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:23:22 | ||
| | ||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:27:22 | ||
| | ||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:23:22 | ||
| | ||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `~const` can only be applied to `#[const_trait]` traits | ||
--> $DIR/const-impl-trait.rs:23:22 | ||
| | ||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; | ||
| ^^^^^^ can't be applied to `PartialEq` | ||
| | ||
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error[E0015]: cannot call non-const operator in constants | ||
--> $DIR/const-impl-trait.rs:35:13 | ||
| | ||
LL | assert!(wrap(123) == wrap(123)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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-impl-trait.rs:36:13 | ||
| | ||
LL | assert!(wrap(123) != wrap(456)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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-impl-trait.rs:38:13 | ||
| | ||
LL | assert!(x == x); | ||
| ^^^^^^ | ||
| | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
|
||
error[E0015]: cannot call non-const operator in constant functions | ||
--> $DIR/const-impl-trait.rs:12:5 | ||
| | ||
LL | a == a | ||
| ^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to 20 previous errors | ||
|
||
Some errors have detailed explanations: E0015, E0635. | ||
For more information about an error, try `rustc --explain E0015`. |