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