File tree Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ use std:: ops:: Add ;
2+
3+ trait Trait < T > {
4+ fn get ( self ) -> T ;
5+ }
6+
7+ struct Holder < T > ( T ) ;
8+
9+ impl < T > Trait < T > for Holder < T > {
10+ fn get ( self ) -> T {
11+ self . 0
12+ }
13+ }
14+
15+ enum Either < L , R > {
16+ Left ( L ) ,
17+ Right ( R ) ,
18+ }
19+
20+ impl < L , R > Either < L , R > {
21+ fn converge < T > ( self ) -> T where L : Trait < T > , R : Trait < T > {
22+ match self {
23+ Either :: Left ( val) => val. get ( ) ,
24+ Either :: Right ( val) => val. get ( ) ,
25+ }
26+ }
27+ }
28+
29+ fn add_generic < A : Add < B > , B > ( lhs : A , rhs : B ) -> Either <
30+ impl Trait < <A as Add < B > >:: Output > ,
31+ impl Trait < <A as Add < B > >:: Output >
32+ > {
33+ if true {
34+ Either :: Left ( Holder ( lhs + rhs) )
35+ } else {
36+ Either :: Right ( Holder ( lhs + rhs) )
37+ }
38+ }
39+
40+ fn add_one (
41+ value : u32 ,
42+ ) -> Either < impl Trait < <u32 as Add < u32 > >:: Output > , impl Trait < <u32 as Add < u32 > >:: Output > > {
43+ //~^ ERROR: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait<u32>`
44+ //~| ERROR: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait<u32>`
45+ add_generic ( value, 1u32 )
46+ }
47+
48+ pub fn main ( ) {
49+ add_one ( 3 ) . converge ( ) ;
50+ }
Original file line number Diff line number Diff line change 1+ error[E0277]: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait<u32>` is not satisfied
2+ --> $DIR/issue-58344.rs:42:13
3+ |
4+ LL | ) -> Either<impl Trait<<u32 as Add<u32>>::Output>, impl Trait<<u32 as Add<u32>>::Output>> {
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<u32>` is not implemented for `impl Trait<<u32 as std::ops::Add>::Output>`
6+ |
7+ = note: the return type of a function must have a statically known size
8+
9+ error[E0277]: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait<u32>` is not satisfied
10+ --> $DIR/issue-58344.rs:42:52
11+ |
12+ LL | ) -> Either<impl Trait<<u32 as Add<u32>>::Output>, impl Trait<<u32 as Add<u32>>::Output>> {
13+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<u32>` is not implemented for `impl Trait<<u32 as std::ops::Add>::Output>`
14+ |
15+ = note: the return type of a function must have a statically known size
16+
17+ error: aborting due to 2 previous errors
18+
19+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments