Rollup merge of #67934 - GuillaumeGomez:clean-up-e0178, r=Dylan-DPC
Clean up E0178 explanation r? @Dylan-DPC
This commit is contained in:
commit
1e7a6a8b5c
1 changed files with 18 additions and 7 deletions
|
@ -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!
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue