]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/impl-trait-plus-priority.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / impl-trait / impl-trait-plus-priority.rs
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 + {} // OK
14 fn f() -> impl A + B {} // OK
15 fn f() -> dyn A + B {} // OK
16 fn f() -> A + B {} // OK
17
18 impl S {
19     fn f(self) -> impl A + { // OK
20         let _ = |a, b| -> impl A + {}; // OK
21     }
22     fn f(self) -> impl A + B { // OK
23         let _ = |a, b| -> impl A + B {}; // OK
24     }
25     fn f(self) -> dyn A + B { // OK
26         let _ = |a, b| -> dyn A + B {}; // OK
27     }
28     fn f(self) -> A + B { // OK
29         let _ = |a, b| -> A + B {}; // OK
30     }
31 }
32
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`
41
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
49
50 type A = &impl A +;
51 //~^ ERROR ambiguous `+` in a type
52 type A = &impl A + B;
53 //~^ ERROR ambiguous `+` in a type
54 type A = &dyn A + B;
55 //~^ ERROR ambiguous `+` in a type
56 type A = &A + B;
57 //~^ ERROR expected a path on the left-hand side of `+`, not `&A`
58
59 fn main() {}