File tree Expand file tree Collapse file tree 6 files changed +125
-0
lines changed Expand file tree Collapse file tree 6 files changed +125
-0
lines changed Original file line number Diff line number Diff line change 1+ trait Foo {
2+ fn foo ( [ a, b] : [ i32 ; 2 ] ) { }
3+ //~^ ERROR: patterns aren't allowed in methods without bodies
4+ }
5+
6+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0642]: patterns aren't allowed in methods without bodies
2+ --> $DIR/issue-50571.rs:2:12
3+ |
4+ LL | fn foo([a, b]: [i32; 2]) {}
5+ | ^^^^^^
6+ help: give this argument a name or use an underscore to ignore it
7+ |
8+ LL | fn foo(_: [i32; 2]) {}
9+ | ^
10+
11+ error: aborting due to previous error
12+
13+ For more information about this error, try `rustc --explain E0642`.
Original file line number Diff line number Diff line change 1+ pub trait Foo : Sized {
2+ const SIZE : usize ;
3+
4+ fn new ( slice : & [ u8 ; Foo :: SIZE ] ) -> Self ;
5+ //~^ ERROR: type annotations needed: cannot resolve `_: Foo`
6+ }
7+
8+ pub struct Bar < T : ?Sized > ( T ) ;
9+
10+ impl Bar < [ u8 ] > {
11+ const SIZE : usize = 32 ;
12+
13+ fn new ( slice : & [ u8 ; Self :: SIZE ] ) -> Self {
14+ Foo ( Box :: new ( * slice) ) //~ ERROR: expected function, found trait `Foo`
15+ }
16+ }
17+
18+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0423]: expected function, found trait `Foo`
2+ --> $DIR/issue-58022.rs:14:9
3+ |
4+ LL | Foo(Box::new(*slice))
5+ | ^^^ not a function
6+
7+ error[E0283]: type annotations needed: cannot resolve `_: Foo`
8+ --> $DIR/issue-58022.rs:4:25
9+ |
10+ LL | const SIZE: usize;
11+ | ------------------ required by `Foo::SIZE`
12+ LL |
13+ LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
14+ | ^^^^^^^^^
15+
16+ error: aborting due to 2 previous errors
17+
18+ Some errors have detailed explanations: E0283, E0423.
19+ For more information about an error, try `rustc --explain E0283`.
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