|
| 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. |
| 4 | +// |
| 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. |
| 10 | + |
| 11 | +// compile-flags: -Z parse-only -Z continue-parse-after-error |
| 12 | + |
| 13 | +fn f() -> impl A + B {} // OK |
| 14 | +fn f() -> dyn A + B {} // OK |
| 15 | +fn f() -> A + B {} // OK |
| 16 | + |
| 17 | +impl S { |
| 18 | + fn f(self) -> impl A + B { // OK |
| 19 | + let _ = |a, b| -> impl A + B {}; // OK |
| 20 | + } |
| 21 | + fn f(self) -> dyn A + B { // OK |
| 22 | + let _ = |a, b| -> dyn A + B {}; // OK |
| 23 | + } |
| 24 | + fn f(self) -> A + B { // OK |
| 25 | + let _ = |a, b| -> A + B {}; // OK |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +type A = fn() -> impl A + B; |
| 30 | +//~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> impl A` |
| 31 | +type A = fn() -> dyn A + B; |
| 32 | +//~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> dyn A` |
| 33 | +type A = fn() -> A + B; |
| 34 | +//~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> A` |
| 35 | + |
| 36 | +type A = Fn() -> impl A + B; // OK, interpreted as `(Fn() -> impl A) + B` |
| 37 | +type A = Fn() -> dyn A + B; // OK, interpreted as `(Fn() -> dyn A) + B` |
| 38 | +type A = Fn() -> A + B; // OK, interpreted as `(Fn() -> A) + B` |
| 39 | + |
| 40 | +type A = &impl A + B; |
| 41 | +//~^ ERROR expected a path on the left-hand side of `+`, not `&impl A` |
| 42 | +type A = &dyn A + B; |
| 43 | +//~^ ERROR expected a path on the left-hand side of `+`, not `&dyn A` |
| 44 | +type A = &A + B; |
| 45 | +//~^ ERROR expected a path on the left-hand side of `+`, not `&A` |
| 46 | + |
| 47 | +fn main() {} |
0 commit comments