1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // compile-flags: -Z parse-only -Z continue-parse-after-error
13 fn f() -> impl A + {} // OK
14 fn f() -> impl A + B {} // OK
15 fn f() -> dyn A + B {} // OK
16 fn f() -> A + B {} // OK
19 fn f(self) -> impl A + { // OK
20 let _ = |a, b| -> impl A + {}; // OK
22 fn f(self) -> impl A + B { // OK
23 let _ = |a, b| -> impl A + B {}; // OK
25 fn f(self) -> dyn A + B { // OK
26 let _ = |a, b| -> dyn A + B {}; // OK
28 fn f(self) -> A + B { // OK
29 let _ = |a, b| -> A + B {}; // OK
33 type A = fn() -> impl A +;
34 //~^ ERROR ambiguous `+` in a type
35 type A = fn() -> impl A + B;
36 //~^ ERROR ambiguous `+` in a type
37 type A = fn() -> dyn A + B;
38 //~^ ERROR ambiguous `+` in a type
39 type A = fn() -> A + B;
40 //~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> A`
42 type A = Fn() -> impl A +;
43 //~^ ERROR ambiguous `+` in a type
44 type A = Fn() -> impl A + B;
45 //~^ ERROR ambiguous `+` in a type
46 type A = Fn() -> dyn A + B;
47 //~^ ERROR ambiguous `+` in a type
48 type A = Fn() -> A + B; // OK, interpreted as `(Fn() -> A) + B` for compatibility
51 //~^ ERROR ambiguous `+` in a type
53 //~^ ERROR ambiguous `+` in a type
55 //~^ ERROR ambiguous `+` in a type
57 //~^ ERROR expected a path on the left-hand side of `+`, not `&A`