]> git.lizzy.rs Git - rust.git/blob - tests/ui/impl-trait/impl-trait-plus-priority.rs
Rollup merge of #106427 - mejrs:translation_errors, r=davidtwco
[rust.git] / tests / ui / impl-trait / impl-trait-plus-priority.rs
1 // compile-flags: -Z parse-only
2
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
7
8 impl S {
9     fn f(self) -> impl A + { // OK
10         let _ = |a, b| -> impl A + {}; // OK
11     }
12     fn f(self) -> impl A + B { // OK
13         let _ = |a, b| -> impl A + B {}; // OK
14     }
15     fn f(self) -> dyn A + B { // OK
16         let _ = |a, b| -> dyn A + B {}; // OK
17     }
18     fn f(self) -> A + B { // OK
19         let _ = |a, b| -> A + B {}; // OK
20     }
21 }
22
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`
31
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
39
40 type A = &impl A +;
41 //~^ ERROR ambiguous `+` in a type
42 type A = &impl A + B;
43 //~^ ERROR ambiguous `+` in a type
44 type A = &dyn A + B;
45 //~^ ERROR ambiguous `+` in a type
46 type A = &A + B;
47 //~^ ERROR expected a path on the left-hand side of `+`, not `&A`
48
49 fn main() {}