File tree 1 file changed +23
-2
lines changed
src/test/ui/rfc-2632-const-trait-impl
1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 1
1
// check-pass
2
- #![ feature( associated_type_bounds, const_trait_impl, const_cmp) ]
2
+ #![ allow( incomplete_features) ]
3
+ #![ feature(
4
+ associated_type_bounds,
5
+ const_trait_impl,
6
+ const_cmp,
7
+ return_position_impl_trait_in_trait,
8
+ ) ]
3
9
4
10
use std:: marker:: Destruct ;
5
11
6
12
const fn cmp ( a : & impl ~const PartialEq ) -> bool {
7
13
a == a
8
14
}
9
15
10
- const fn wrap ( x : impl ~const PartialEq + ~const Destruct ) -> impl ~const PartialEq + ~const Destruct {
16
+ const fn wrap ( x : impl ~const PartialEq + ~const Destruct )
17
+ -> impl ~const PartialEq + ~const Destruct
18
+ {
11
19
x
12
20
}
13
21
22
+ #[ const_trait]
23
+ trait Foo {
24
+ fn huh ( ) -> impl ~const PartialEq + ~const Destruct + Copy ;
25
+ }
26
+
27
+ impl const Foo for ( ) {
28
+ fn huh ( ) -> impl ~const PartialEq + ~const Destruct + Copy {
29
+ 123
30
+ }
31
+ }
32
+
14
33
const _: ( ) = {
15
34
assert ! ( cmp( & 0xDEADBEEFu32 ) ) ;
16
35
assert ! ( cmp( & ( ) ) ) ;
17
36
assert ! ( wrap( 123 ) == wrap( 123 ) ) ;
18
37
assert ! ( wrap( 123 ) != wrap( 456 ) ) ;
38
+ let x = <( ) as Foo >:: huh ( ) ;
39
+ assert ! ( x == x) ;
19
40
} ;
20
41
21
42
#[ const_trait]
You can’t perform that action at this time.
0 commit comments