1 // compile-flags: -Z parse-only
3 fn f() -> impl A + {} // OK
4 fn f() -> impl A + B {} // OK
5 fn f() -> dyn A + B {} // OK
6 fn f() -> A + B {} // OK
9 fn f(self) -> impl A + { // OK
10 let _ = |a, b| -> impl A + {}; // OK
12 fn f(self) -> impl A + B { // OK
13 let _ = |a, b| -> impl A + B {}; // OK
15 fn f(self) -> dyn A + B { // OK
16 let _ = |a, b| -> dyn A + B {}; // OK
18 fn f(self) -> A + B { // OK
19 let _ = |a, b| -> A + B {}; // OK
23 type A = fn() -> impl A +;
24 //~^ ERROR ambiguous `+` in a type
25 type A = fn() -> impl A + B;
26 //~^ ERROR ambiguous `+` in a type
27 type A = fn() -> dyn A + B;
28 //~^ ERROR ambiguous `+` in a type
29 type A = fn() -> A + B;
30 //~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> A`
32 type A = Fn() -> impl A +;
33 //~^ ERROR ambiguous `+` in a type
34 type A = Fn() -> impl A + B;
35 //~^ ERROR ambiguous `+` in a type
36 type A = Fn() -> dyn A + B;
37 //~^ ERROR ambiguous `+` in a type
38 type A = Fn() -> A + B; // OK, interpreted as `(Fn() -> A) + B` for compatibility
41 //~^ ERROR ambiguous `+` in a type
43 //~^ ERROR ambiguous `+` in a type
45 //~^ ERROR ambiguous `+` in a type
47 //~^ ERROR expected a path on the left-hand side of `+`, not `&A`