Skip to content

Commit 4f6558b

Browse files
committed
Update tests
1 parent d572a90 commit 4f6558b

14 files changed

+88
-125
lines changed

tests/ui/consts/rustc-impl-const-stability.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub struct Data {
1212

1313
#[stable(feature = "potato", since = "1.27.0")]
1414
#[rustc_const_unstable(feature = "data_foo", issue = "none")]
15-
impl const Default for Data {
16-
fn default() -> Data {
17-
Data { _data: 42 }
15+
impl const std::fmt::Debug for Data {
16+
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
17+
panic!()
1818
}
1919
}

tests/ui/consts/rustc-impl-const-stability.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
1+
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]`
22
--> $DIR/rustc-impl-const-stability.rs:15:12
33
|
4-
LL | impl const Default for Data {
5-
| ^^^^^^^ this trait is not `const`
4+
LL | impl const std::fmt::Debug for Data {
5+
| ^^^^^^^^^^^^^^^ this trait is not `const`
66
|
77
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
88
= note: adding a non-const method body in the future would be a breaking change

tests/ui/specialization/const_trait_impl.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#![feature(const_trait_impl, min_specialization, rustc_attrs)]
44

5+
use std::fmt::Debug;
6+
57
#[rustc_specialization_trait]
68
#[const_trait]
79
pub unsafe trait Sup {
@@ -31,19 +33,19 @@ pub trait A {
3133
fn a() -> u32;
3234
}
3335

34-
impl<T: ~const Default> const A for T {
36+
impl<T: ~const Debug> const A for T {
3537
default fn a() -> u32 {
3638
2
3739
}
3840
}
3941

40-
impl<T: ~const Default + ~const Sup> const A for T {
42+
impl<T: ~const Debug + ~const Sup> const A for T {
4143
default fn a() -> u32 {
4244
3
4345
}
4446
}
4547

46-
impl<T: ~const Default + ~const Sub> const A for T {
48+
impl<T: ~const Debug + ~const Sub> const A for T {
4749
fn a() -> u32 {
4850
T::foo()
4951
}

tests/ui/specialization/const_trait_impl.stderr

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
error: `~const` can only be applied to `#[const_trait]` traits
2-
--> $DIR/const_trait_impl.rs:34:9
2+
--> $DIR/const_trait_impl.rs:36:9
33
|
4-
LL | impl<T: ~const Default> const A for T {
5-
| ^^^^^^ can't be applied to `Default`
4+
LL | impl<T: ~const Debug> const A for T {
5+
| ^^^^^^ can't be applied to `Debug`
66
|
7-
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
8-
--> $SRC_DIR/core/src/default.rs:LL:COL
7+
note: `Debug` can't be used with `~const` because it isn't annotated with `#[const_trait]`
8+
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
99

1010
error: `~const` can only be applied to `#[const_trait]` traits
11-
--> $DIR/const_trait_impl.rs:40:9
11+
--> $DIR/const_trait_impl.rs:42:9
1212
|
13-
LL | impl<T: ~const Default + ~const Sup> const A for T {
14-
| ^^^^^^ can't be applied to `Default`
13+
LL | impl<T: ~const Debug + ~const Sup> const A for T {
14+
| ^^^^^^ can't be applied to `Debug`
1515
|
16-
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
17-
--> $SRC_DIR/core/src/default.rs:LL:COL
16+
note: `Debug` can't be used with `~const` because it isn't annotated with `#[const_trait]`
17+
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
1818

1919
error: `~const` can only be applied to `#[const_trait]` traits
20-
--> $DIR/const_trait_impl.rs:46:9
20+
--> $DIR/const_trait_impl.rs:48:9
2121
|
22-
LL | impl<T: ~const Default + ~const Sub> const A for T {
23-
| ^^^^^^ can't be applied to `Default`
22+
LL | impl<T: ~const Debug + ~const Sub> const A for T {
23+
| ^^^^^^ can't be applied to `Debug`
2424
|
25-
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
26-
--> $SRC_DIR/core/src/default.rs:LL:COL
25+
note: `Debug` can't be used with `~const` because it isn't annotated with `#[const_trait]`
26+
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
2727

2828
error: `~const` can only be applied to `#[const_trait]` traits
29-
--> $DIR/const_trait_impl.rs:40:9
29+
--> $DIR/const_trait_impl.rs:42:9
3030
|
31-
LL | impl<T: ~const Default + ~const Sup> const A for T {
32-
| ^^^^^^ can't be applied to `Default`
31+
LL | impl<T: ~const Debug + ~const Sup> const A for T {
32+
| ^^^^^^ can't be applied to `Debug`
3333
|
34-
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
35-
--> $SRC_DIR/core/src/default.rs:LL:COL
34+
note: `Debug` can't be used with `~const` because it isn't annotated with `#[const_trait]`
35+
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
3636
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3737

3838
error: `~const` can only be applied to `#[const_trait]` traits
39-
--> $DIR/const_trait_impl.rs:34:9
39+
--> $DIR/const_trait_impl.rs:36:9
4040
|
41-
LL | impl<T: ~const Default> const A for T {
42-
| ^^^^^^ can't be applied to `Default`
41+
LL | impl<T: ~const Debug> const A for T {
42+
| ^^^^^^ can't be applied to `Debug`
4343
|
44-
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
45-
--> $SRC_DIR/core/src/default.rs:LL:COL
44+
note: `Debug` can't be used with `~const` because it isn't annotated with `#[const_trait]`
45+
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
4646
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
4747

4848
error: `~const` can only be applied to `#[const_trait]` traits
49-
--> $DIR/const_trait_impl.rs:46:9
49+
--> $DIR/const_trait_impl.rs:48:9
5050
|
51-
LL | impl<T: ~const Default + ~const Sub> const A for T {
52-
| ^^^^^^ can't be applied to `Default`
51+
LL | impl<T: ~const Debug + ~const Sub> const A for T {
52+
| ^^^^^^ can't be applied to `Debug`
5353
|
54-
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
55-
--> $SRC_DIR/core/src/default.rs:LL:COL
54+
note: `Debug` can't be used with `~const` because it isn't annotated with `#[const_trait]`
55+
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
5656
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5757

5858
error: aborting due to 6 previous errors
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#[derive_const(Default)] //~ ERROR use of unstable library feature
2-
//~^ ERROR const `impl` for trait `Default` which is not marked with `#[const_trait]`
1+
#[derive_const(Debug)] //~ ERROR use of unstable library feature
2+
//~^ ERROR const `impl` for trait `Debug` which is not marked with `#[const_trait]`
3+
//~| ERROR cannot call non-const method
34
pub struct S;
45

56
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
error[E0658]: use of unstable library feature `derive_const`
22
--> $DIR/derive-const-gate.rs:1:3
33
|
4-
LL | #[derive_const(Default)]
4+
LL | #[derive_const(Debug)]
55
| ^^^^^^^^^^^^
66
|
77
= help: add `#![feature(derive_const)]` to the crate attributes to enable
88
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
99

10-
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
10+
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]`
1111
--> $DIR/derive-const-gate.rs:1:16
1212
|
13-
LL | #[derive_const(Default)]
14-
| ^^^^^^^ this trait is not `const`
13+
LL | #[derive_const(Debug)]
14+
| ^^^^^ this trait is not `const`
1515
|
1616
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
1717
= note: adding a non-const method body in the future would be a breaking change
18-
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
18+
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
1919

20-
error: aborting due to 2 previous errors
20+
error[E0015]: cannot call non-const method `Formatter::<'_>::write_str` in constant functions
21+
--> $DIR/derive-const-gate.rs:1:16
22+
|
23+
LL | #[derive_const(Debug)]
24+
| ^^^^^
25+
|
26+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
27+
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
28+
29+
error: aborting due to 3 previous errors
2130

22-
For more information about this error, try `rustc --explain E0658`.
31+
Some errors have detailed explanations: E0015, E0658.
32+
For more information about an error, try `rustc --explain E0015`.

tests/ui/traits/const-traits/const_derives/derive-const-non-const-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ impl Default for A {
77
fn default() -> A { A }
88
}
99

10-
#[derive_const(Default)]
10+
#[derive_const(Debug)]
1111
pub struct S(A);
1212

1313
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
1+
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]`
22
--> $DIR/derive-const-non-const-type.rs:10:16
33
|
4-
LL | #[derive_const(Default)]
5-
| ^^^^^^^ this trait is not `const`
4+
LL | #[derive_const(Debug)]
5+
| ^^^^^ this trait is not `const`
66
|
77
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
88
= note: adding a non-const method body in the future would be a breaking change
9-
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
9+
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
1010

11-
error[E0015]: cannot call non-const associated function `<A as Default>::default` in constant functions
11+
error[E0277]: `A` doesn't implement `Debug`
1212
--> $DIR/derive-const-non-const-type.rs:11:14
1313
|
14-
LL | #[derive_const(Default)]
15-
| ------- in this derive macro expansion
14+
LL | #[derive_const(Debug)]
15+
| ----- in this derive macro expansion
1616
LL | pub struct S(A);
17-
| ^
17+
| ^ `A` cannot be formatted using `{:?}`
18+
|
19+
= help: the trait `Debug` is not implemented for `A`
20+
= note: add `#[derive(Debug)]` to `A` or manually `impl Debug for A`
21+
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
help: consider annotating `A` with `#[derive(Debug)]`
23+
|
24+
LL + #[derive(Debug)]
25+
LL | pub struct A;
1826
|
19-
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
20-
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
2127

2228
error: aborting due to 2 previous errors
2329

24-
For more information about this error, try `rustc --explain E0015`.
30+
For more information about this error, try `rustc --explain E0277`.

tests/ui/traits/const-traits/const_derives/derive-const-use.stderr

+1-50
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,6 @@ error[E0635]: unknown feature `const_default_impls`
1010
LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
1111
| ^^^^^^^^^^^^^^^^^^^
1212

13-
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
14-
--> $DIR/derive-const-use.rs:7:12
15-
|
16-
LL | impl const Default for A {
17-
| ^^^^^^^ this trait is not `const`
18-
|
19-
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
20-
= note: adding a non-const method body in the future would be a breaking change
21-
22-
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
23-
--> $DIR/derive-const-use.rs:15:16
24-
|
25-
LL | #[derive_const(Default, PartialEq)]
26-
| ^^^^^^^ this trait is not `const`
27-
|
28-
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
29-
= note: adding a non-const method body in the future would be a breaking change
30-
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
31-
3213
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
3314
--> $DIR/derive-const-use.rs:11:12
3415
|
@@ -48,14 +29,6 @@ LL | #[derive_const(Default, PartialEq)]
4829
= note: adding a non-const method body in the future would be a breaking change
4930
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
5031

51-
error[E0015]: cannot call non-const associated function `<S as Default>::default` in constants
52-
--> $DIR/derive-const-use.rs:18:35
53-
|
54-
LL | const _: () = assert!(S((), A) == S::default());
55-
| ^^^^^^^^^^^^
56-
|
57-
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
58-
5932
error[E0015]: cannot call non-const operator in constants
6033
--> $DIR/derive-const-use.rs:18:23
6134
|
@@ -64,28 +37,6 @@ LL | const _: () = assert!(S((), A) == S::default());
6437
|
6538
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
6639

67-
error[E0015]: cannot call non-const associated function `<() as Default>::default` in constant functions
68-
--> $DIR/derive-const-use.rs:16:14
69-
|
70-
LL | #[derive_const(Default, PartialEq)]
71-
| ------- in this derive macro expansion
72-
LL | pub struct S((), A);
73-
| ^^
74-
|
75-
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
76-
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
77-
78-
error[E0015]: cannot call non-const associated function `<A as Default>::default` in constant functions
79-
--> $DIR/derive-const-use.rs:16:18
80-
|
81-
LL | #[derive_const(Default, PartialEq)]
82-
| ------- in this derive macro expansion
83-
LL | pub struct S((), A);
84-
| ^
85-
|
86-
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
87-
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
88-
8940
error[E0015]: cannot call non-const operator in constant functions
9041
--> $DIR/derive-const-use.rs:16:14
9142
|
@@ -108,7 +59,7 @@ LL | pub struct S((), A);
10859
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
10960
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
11061

111-
error: aborting due to 12 previous errors
62+
error: aborting due to 7 previous errors
11263

11364
Some errors have detailed explanations: E0015, E0635.
11465
For more information about an error, try `rustc --explain E0015`.

tests/ui/traits/const-traits/std-impl-gate.gated.stderr

+2-11
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ error[E0635]: unknown feature `const_default_impls`
44
LL | #![cfg_attr(gated, feature(const_trait_impl, const_default_impls))]
55
| ^^^^^^^^^^^^^^^^^^^
66

7-
error[E0015]: cannot call non-const associated function `<Vec<usize> as Default>::default` in constant functions
8-
--> $DIR/std-impl-gate.rs:13:5
9-
|
10-
LL | Default::default()
11-
| ^^^^^^^^^^^^^^^^^^
12-
|
13-
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
14-
15-
error: aborting due to 2 previous errors
7+
error: aborting due to 1 previous error
168

17-
Some errors have detailed explanations: E0015, E0635.
18-
For more information about an error, try `rustc --explain E0015`.
9+
For more information about this error, try `rustc --explain E0635`.

tests/ui/traits/const-traits/std-impl-gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn non_const_context() -> Vec<usize> {
1111

1212
const fn const_context() -> Vec<usize> {
1313
Default::default()
14-
//[stock]~^ ERROR cannot call non-const associated function
14+
//[stock]~^ ERROR cannot call conditionally-const associated function
1515
}
1616

1717
fn main() {
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
error[E0015]: cannot call non-const associated function `<Vec<usize> as Default>::default` in constant functions
1+
error[E0658]: cannot call conditionally-const associated function `<Vec<usize> as Default>::default` in constant functions
22
--> $DIR/std-impl-gate.rs:13:5
33
|
44
LL | Default::default()
55
| ^^^^^^^^^^^^^^^^^^
66
|
7-
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
7+
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
8+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
810

911
error: aborting due to 1 previous error
1012

11-
For more information about this error, try `rustc --explain E0015`.
13+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)