]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0178.md
Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyup
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0178.md
1 The `+` type operator was used in an ambiguous context.
2
3 Erroneous code example:
4
5 ```compile_fail,E0178
6 trait Foo {}
7
8 struct Bar<'a> {
9     x: &'a Foo + 'a,     // error!
10     y: &'a mut Foo + 'a, // error!
11     z: fn() -> Foo + 'a, // error!
12 }
13 ```
14
15 In types, the `+` type operator has low precedence, so it is often necessary
16 to use parentheses:
17
18 ```
19 trait Foo {}
20
21 struct Bar<'a> {
22     x: &'a (Foo + 'a),     // ok!
23     y: &'a mut (Foo + 'a), // ok!
24     z: fn() -> (Foo + 'a), // ok!
25 }
26 ```
27
28 More details can be found in [RFC 438].
29
30 [RFC 438]: https://github.com/rust-lang/rfcs/pull/438