File tree Expand file tree Collapse file tree 3 files changed +38
-8
lines changed
src/test/ui/rfc-2632-const-trait-impl Expand file tree Collapse file tree 3 files changed +38
-8
lines changed Original file line number Diff line number Diff line change 11#![ feature( const_trait_impl) ]
2+ #![ feature( const_fn_trait_bound) ]
23
34trait 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-
2622impl const Tr for u16 {
2723 fn prov ( & self ) { }
2824 fn default ( ) { }
Original file line number Diff line number Diff line change 11error: 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 |
44LL | / impl const Tr for S {
55LL | | fn req(&self) {}
99 = note: `prov` not implemented
1010
1111error: 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 |
1414LL | / impl const Tr for u32 {
1515LL | | fn req(&self) {}
@@ -20,7 +20,7 @@ LL | | }
2020 = note: `prov` not implemented
2121
2222error[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 |
2525LL | fn req(&self);
2626 | -------------- `req` from trait
Original file line number Diff line number Diff line change 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 ( ) { }
You can’t perform that action at this time.
0 commit comments