Skip to content

Commit 799c06f

Browse files
authored
Rollup merge of #150728 - fee1-dead-contrib:const-traits-test-cleanup, r=fmease
Cleanup some ui tests for const-traits r? project-const-traits These tests pretty much behave as expected now.
2 parents 9c45483 + d101412 commit 799c06f

14 files changed

+35
-212
lines changed

‎tests/ui/const-generics/issues/issue-88119.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//@ known-bug: #110395
2-
//@ compile-flags: -Znext-solver
1+
//@ check-pass
32
#![allow(incomplete_features)]
43
#![feature(const_trait_impl, generic_const_exprs)]
54

‎tests/ui/const-generics/issues/issue-88119.stderr‎

Lines changed: 0 additions & 95 deletions
This file was deleted.

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎tests/ui/specialization/const_trait_impl.stderr‎

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
//@ known-bug: #110395
2-
#![feature(derive_const)]
1+
#![feature(const_default, derive_const)]
32

43
pub struct A;
54

6-
impl std::fmt::Debug for A {
7-
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
8-
panic!()
5+
impl Default for A {
6+
fn default() -> A {
7+
A
98
}
109
}
1110

12-
#[derive_const(Debug)]
11+
#[derive_const(Default)]
1312
pub struct S(A);
13+
//~^ ERROR: cannot call non-const associated function
1414

1515
fn main() {}
Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
error: const `impl` for trait `Debug` which is not `const`
2-
--> $DIR/derive-const-non-const-type.rs:12:16
1+
error[E0015]: cannot call non-const associated function `<A as Default>::default` in constant functions
2+
--> $DIR/derive-const-non-const-type.rs:12:14
33
|
4-
LL | #[derive_const(Debug)]
5-
| ^^^^^ this trait is not `const`
6-
|
7-
= note: marking a trait with `const` ensures all default method bodies are `const`
8-
= note: adding a non-const method body in the future would be a breaking change
9-
10-
error[E0015]: cannot call non-const method `Formatter::<'_>::debug_tuple_field1_finish` in constant functions
11-
--> $DIR/derive-const-non-const-type.rs:12:16
12-
|
13-
LL | #[derive_const(Debug)]
14-
| ^^^^^
4+
LL | #[derive_const(Default)]
5+
| ------- in this derive macro expansion
6+
LL | pub struct S(A);
7+
| ^
158
|
169
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
1710

18-
error: aborting due to 2 previous errors
11+
error: aborting due to 1 previous error
1912

2013
For more information about this error, try `rustc --explain E0015`.
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//@ compile-flags: -Znext-solver
2-
//@ known-bug: #110395
1+
//@ check-pass
32

43
#![crate_type = "lib"]
54
#![feature(staged_api, const_trait_impl, const_default)]
@@ -12,8 +11,8 @@ pub struct Data {
1211

1312
#[stable(feature = "potato", since = "1.27.0")]
1413
#[rustc_const_unstable(feature = "data_foo", issue = "none")]
15-
impl const std::fmt::Debug for Data {
16-
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
17-
Ok(())
14+
impl const Default for Data {
15+
fn default() -> Data {
16+
Data { _data: 0xbeef }
1817
}
1918
}

‎tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Tests that trait bounds on specializing trait impls must be `[const]` if the
22
// same bound is present on the default impl and is `[const]` there.
3-
//@ known-bug: #110395
4-
// FIXME(const_trait_impl) ^ should error
53

64
#![feature(const_trait_impl)]
75
#![feature(rustc_attrs)]
@@ -23,9 +21,9 @@ where
2321
default fn bar() {}
2422
}
2523

26-
impl<T> Bar for T
24+
impl<T> Bar for T //~ ERROR conflicting implementations of trait `Bar`
2725
where
28-
T: Foo, //FIXME ~ ERROR missing `[const]` qualifier
26+
T: Foo,
2927
T: Specialize,
3028
{
3129
fn bar() {}
@@ -42,7 +40,7 @@ where
4240
default fn baz() {}
4341
}
4442

45-
impl<T> const Baz for T //FIXME ~ ERROR conflicting implementations of trait `Baz`
43+
impl<T> const Baz for T //~ ERROR conflicting implementations of trait `Baz`
4644
where
4745
T: Foo,
4846
T: Specialize,

‎tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0119]: conflicting implementations of trait `Bar`
2-
--> $DIR/const-default-bound-non-const-specialized-bound.rs:26:1
2+
--> $DIR/const-default-bound-non-const-specialized-bound.rs:24:1
33
|
44
LL | / impl<T> const Bar for T
55
LL | | where
@@ -8,19 +8,19 @@ LL | | T: [const] Foo,
88
...
99
LL | / impl<T> Bar for T
1010
LL | | where
11-
LL | | T: Foo, //FIXME ~ ERROR missing `[const]` qualifier
11+
LL | | T: Foo,
1212
LL | | T: Specialize,
1313
| |__________________^ conflicting implementation
1414

1515
error[E0119]: conflicting implementations of trait `Baz`
16-
--> $DIR/const-default-bound-non-const-specialized-bound.rs:45:1
16+
--> $DIR/const-default-bound-non-const-specialized-bound.rs:43:1
1717
|
1818
LL | / impl<T> const Baz for T
1919
LL | | where
2020
LL | | T: [const] Foo,
2121
| |___________________- first implementation here
2222
...
23-
LL | / impl<T> const Baz for T //FIXME ~ ERROR conflicting implementations of trait `Baz`
23+
LL | / impl<T> const Baz for T
2424
LL | | where
2525
LL | | T: Foo,
2626
LL | | T: Specialize,

tests/ui/specialization/const_trait_impl.rs renamed to tests/ui/traits/const-traits/specialization/pass.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
//@ known-bug: #110395
2-
3-
#![feature(const_trait_impl, min_specialization, rustc_attrs)]
4-
5-
use std::fmt::Debug;
1+
//@ check-pass
2+
#![feature(const_trait_impl, const_default, min_specialization, rustc_attrs)]
3+
#![allow(internal_features)]
64

75
#[rustc_specialization_trait]
86
pub const unsafe trait Sup {
@@ -30,19 +28,19 @@ pub const trait A {
3028
fn a() -> u32;
3129
}
3230

33-
impl<T: [const] Debug> const A for T {
31+
impl<T: [const] Default> const A for T {
3432
default fn a() -> u32 {
3533
2
3634
}
3735
}
3836

39-
impl<T: [const] Debug + [const] Sup> const A for T {
37+
impl<T: [const] Default + [const] Sup> const A for T {
4038
default fn a() -> u32 {
4139
3
4240
}
4341
}
4442

45-
impl<T: [const] Debug + [const] Sub> const A for T {
43+
impl<T: [const] Default + [const] Sub> const A for T {
4644
fn a() -> u32 {
4745
T::foo()
4846
}

0 commit comments

Comments
 (0)