Skip to content

Commit 0a03f8c

Browse files
committed
Split impl-with-default-fn test into a pass test and a fail test
1 parent de940fc commit 0a03f8c

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.rs renamed to src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(const_trait_impl)]
2+
#![feature(const_fn_trait_bound)]
23

34
trait Tr {
45
fn req(&self);
@@ -18,11 +19,6 @@ impl const Tr for S {
1819
fn req(&self) {}
1920
} //~^^ ERROR const trait implementations may not use non-const default functions
2021

21-
impl const Tr for u8 {
22-
fn req(&self) {}
23-
fn prov(&self) {}
24-
}
25-
2622
impl const Tr for u16 {
2723
fn prov(&self) {}
2824
fn default() {}

src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn.stderr renamed to src/test/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: const trait implementations may not use non-const default functions
2-
--> $DIR/impl-with-default-fn.rs:17:1
2+
--> $DIR/impl-with-default-fn-fail.rs:18:1
33
|
44
LL | / impl const Tr for S {
55
LL | | fn req(&self) {}
@@ -9,7 +9,7 @@ LL | | }
99
= note: `prov` not implemented
1010

1111
error: const trait implementations may not use non-const default functions
12-
--> $DIR/impl-with-default-fn.rs:32:1
12+
--> $DIR/impl-with-default-fn-fail.rs:28:1
1313
|
1414
LL | / impl const Tr for u32 {
1515
LL | | fn req(&self) {}
@@ -20,7 +20,7 @@ LL | | }
2020
= note: `prov` not implemented
2121

2222
error[E0046]: not all trait items implemented, missing: `req`
23-
--> $DIR/impl-with-default-fn.rs:26:1
23+
--> $DIR/impl-with-default-fn-fail.rs:22:1
2424
|
2525
LL | fn req(&self);
2626
| -------------- `req` from trait
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// check-pass
2+
3+
#![feature(const_trait_impl)]
4+
#![feature(const_fn_trait_bound)]
5+
6+
trait Tr {
7+
fn req(&self);
8+
9+
fn prov(&self) {
10+
println!("lul");
11+
self.req();
12+
}
13+
14+
#[default_method_body_is_const]
15+
fn default() {}
16+
}
17+
18+
impl const Tr for u8 {
19+
fn req(&self) {}
20+
fn prov(&self) {}
21+
}
22+
23+
macro_rules! impl_tr {
24+
($ty: ty) => {
25+
impl const Tr for $ty {
26+
fn req(&self) {}
27+
fn prov(&self) {}
28+
}
29+
}
30+
}
31+
32+
impl_tr!(u64);
33+
34+
fn main() {}

0 commit comments

Comments
 (0)