-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
88 additions
and
125 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
5 changes: 3 additions & 2 deletions
5
tests/ui/traits/const-traits/const_derives/derive-const-gate.rs
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,5 +1,6 @@ | ||
#[derive_const(Default)] //~ ERROR use of unstable library feature | ||
//~^ ERROR const `impl` for trait `Default` which is not marked with `#[const_trait]` | ||
#[derive_const(Debug)] //~ ERROR use of unstable library feature | ||
//~^ ERROR const `impl` for trait `Debug` which is not marked with `#[const_trait]` | ||
//~| ERROR cannot call non-const fn | ||
pub struct S; | ||
|
||
fn main() {} |
24 changes: 17 additions & 7 deletions
24
tests/ui/traits/const-traits/const_derives/derive-const-gate.stderr
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,22 +1,32 @@ | ||
error[E0658]: use of unstable library feature `derive_const` | ||
--> $DIR/derive-const-gate.rs:1:3 | ||
| | ||
LL | #[derive_const(Default)] | ||
LL | #[derive_const(Debug)] | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: add `#![feature(derive_const)]` 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: const `impl` for trait `Default` which is not marked with `#[const_trait]` | ||
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]` | ||
--> $DIR/derive-const-gate.rs:1:16 | ||
| | ||
LL | #[derive_const(Default)] | ||
| ^^^^^^^ this trait is not `const` | ||
LL | #[derive_const(Debug)] | ||
| ^^^^^ this trait is not `const` | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 2 previous errors | ||
error[E0015]: cannot call non-const fn `Formatter::<'_>::write_str` in constant functions | ||
--> $DIR/derive-const-gate.rs:1:16 | ||
| | ||
LL | #[derive_const(Debug)] | ||
| ^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. | ||
Some errors have detailed explanations: E0015, E0658. | ||
For more information about an error, try `rustc --explain E0015`. |
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
28 changes: 17 additions & 11 deletions
28
tests/ui/traits/const-traits/const_derives/derive-const-non-const-type.stderr
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,24 +1,30 @@ | ||
error: const `impl` for trait `Default` which is not marked with `#[const_trait]` | ||
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]` | ||
--> $DIR/derive-const-non-const-type.rs:10:16 | ||
| | ||
LL | #[derive_const(Default)] | ||
| ^^^^^^^ this trait is not `const` | ||
LL | #[derive_const(Debug)] | ||
| ^^^^^ this trait is not `const` | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0015]: cannot call non-const fn `<A as Default>::default` in constant functions | ||
error[E0277]: `A` doesn't implement `Debug` | ||
--> $DIR/derive-const-non-const-type.rs:11:14 | ||
| | ||
LL | #[derive_const(Default)] | ||
| ------- in this derive macro expansion | ||
LL | #[derive_const(Debug)] | ||
| ----- in this derive macro expansion | ||
LL | pub struct S(A); | ||
| ^ | ||
| ^ `A` cannot be formatted using `{:?}` | ||
| | ||
= help: the trait `Debug` is not implemented for `A` | ||
= note: add `#[derive(Debug)]` to `A` or manually `impl Debug for A` | ||
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider annotating `A` with `#[derive(Debug)]` | ||
| | ||
LL + #[derive(Debug)] | ||
LL | pub struct A; | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
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
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,11 +1,13 @@ | ||
error[E0015]: cannot call non-const fn `<Vec<usize> as Default>::default` in constant functions | ||
error[E0658]: cannot call conditionally-const associated function `<Vec<usize> as Default>::default` in constant functions | ||
--> $DIR/std-impl-gate.rs:13:5 | ||
| | ||
LL | Default::default() | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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`. |