1
Fork 0

Rollup merge of #67934 - GuillaumeGomez:clean-up-e0178, r=Dylan-DPC

Clean up E0178 explanation

r? @Dylan-DPC
This commit is contained in:
Yuki Okushi 2020-01-07 13:46:12 +09:00 committed by GitHub
commit 1e7a6a8b5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,16 +1,27 @@
In types, the `+` type operator has low precedence, so it is often necessary
to use parentheses.
The `+` type operator was used in an ambiguous context.
For example:
Erroneous code example:
```compile_fail,E0178
trait Foo {}
struct Bar<'a> {
w: &'a Foo + Copy, // error, use &'a (Foo + Copy)
x: &'a Foo + 'a, // error, use &'a (Foo + 'a)
y: &'a mut Foo + 'a, // error, use &'a mut (Foo + 'a)
z: fn() -> Foo + 'a, // error, use fn() -> (Foo + '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!
}
```