This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +94
-0
lines changed
src/test/ui/const-generics/defaults Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Original file line number Diff line number Diff line change 1+ // run-pass
2+ #![ feature( const_generics_defaults) ]
3+
4+ struct Uwu < const N : u32 = 1 , const M : u32 = N > ;
5+
6+ trait Trait { }
7+ impl < const N : u32 > Trait for Uwu < N > { }
8+
9+ fn rawr < const N : u32 > ( ) -> impl Trait {
10+ Uwu :: < N >
11+ }
12+
13+ trait Traitor < const N : u8 = 1 , const M : u8 = N > { }
14+
15+ impl < const N : u8 > Traitor < N > for u32 { }
16+ impl Traitor < 1 , 1 > for u64 { }
17+
18+ fn uwu < const N : u8 > ( ) -> impl Traitor < N > {
19+ 1_u32
20+ }
21+
22+ fn owo ( ) -> impl Traitor {
23+ 1_u64
24+ }
25+
26+ fn main ( ) {
27+ rawr :: < 3 > ( ) ;
28+ rawr :: < 7 > ( ) ;
29+ uwu :: < { u8:: MAX } > ( ) ;
30+ owo ( ) ;
31+ }
Original file line number Diff line number Diff line change 1+ #![ feature( const_generics_defaults) ]
2+
3+ struct Uwu < const N : u32 = 1 , const M : u32 = N > ;
4+
5+ trait Trait { }
6+ impl < const N : u32 > Trait for Uwu < N > { }
7+
8+ fn rawr ( ) -> impl Trait {
9+ //~^ error: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied
10+ Uwu :: < 10 , 12 >
11+ }
12+
13+ trait Traitor < const N : u8 = 1 , const M : u8 = N > { }
14+
15+ impl < const N : u8 > Traitor < N , 2 > for u32 { }
16+ impl Traitor < 1 , 2 > for u64 { }
17+
18+
19+ fn uwu < const N : u8 > ( ) -> impl Traitor < N > {
20+ //~^ error: the trait bound `u32: Traitor<N, N>` is not satisfied
21+ 1_u32
22+ }
23+
24+ fn owo ( ) -> impl Traitor {
25+ //~^ error: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
26+ 1_u64
27+ }
28+
29+ fn main ( ) {
30+ rawr ( ) ;
31+ uwu ( ) ;
32+ owo ( ) ;
33+ }
Original file line number Diff line number Diff line change 1+ error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied
2+ --> $DIR/rp_impl_trait_fail.rs:8:14
3+ |
4+ LL | fn rawr() -> impl Trait {
5+ | ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>`
6+ |
7+ = help: the following implementations were found:
8+ <Uwu<N> as Trait>
9+
10+ error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied
11+ --> $DIR/rp_impl_trait_fail.rs:19:26
12+ |
13+ LL | fn uwu<const N: u8>() -> impl Traitor<N> {
14+ | ^^^^^^^^^^^^^^^ the trait `Traitor<N, N>` is not implemented for `u32`
15+ |
16+ = help: the following implementations were found:
17+ <u32 as Traitor<N, 2_u8>>
18+
19+ error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
20+ --> $DIR/rp_impl_trait_fail.rs:24:13
21+ |
22+ LL | fn owo() -> impl Traitor {
23+ | ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64`
24+ |
25+ = help: the following implementations were found:
26+ <u64 as Traitor<1_u8, 2_u8>>
27+
28+ error: aborting due to 3 previous errors
29+
30+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments