File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
src/test/ui/rfc-2632-const-trait-impl Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ //! Basic test for calling methods on generic type parameters in `const fn`.
2+
3+ // check-pass
4+
5+ #![ feature( const_fn) ]
6+ #![ feature( const_trait_impl) ]
7+ #![ allow( incomplete_features) ]
8+
9+ struct S ;
10+
11+ impl const PartialEq for S {
12+ fn eq ( & self , _: & S ) -> bool {
13+ true
14+ }
15+ }
16+
17+ const fn equals_self < T : PartialEq > ( t : & T ) -> bool {
18+ * t == * t
19+ }
20+
21+ const fn equals_self_wrapper < T : PartialEq > ( t : & T ) -> bool {
22+ equals_self ( t)
23+ }
24+
25+ pub const EQ : bool = equals_self_wrapper ( & S ) ;
26+
27+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ // check-pass
2+
3+ #![ feature( const_fn) ]
4+ #![ feature( const_trait_impl) ]
5+ #![ feature( const_trait_bound_opt_out) ]
6+ #![ allow( incomplete_features) ]
7+
8+ struct S ;
9+
10+ impl const PartialEq for S {
11+ fn eq ( & self , _: & S ) -> bool {
12+ true
13+ }
14+ }
15+
16+ // This duplicate bound should not result in ambiguities. It should be equivalent to a single const
17+ // bound.
18+ const fn equals_self < T : PartialEq + ?const PartialEq > ( t : & T ) -> bool {
19+ * t == * t
20+ }
21+
22+ pub const EQ : bool = equals_self ( & S ) ;
23+
24+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments