Skip to content

Commit

Permalink
Rollup merge of #67934 - GuillaumeGomez:clean-up-e0178, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Clean up E0178 explanation

r? @Dylan-DPC
  • Loading branch information
Dylan-DPC authored Jan 6, 2020
2 parents 068e8df + 99fda5c commit d6b7b17
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/librustc_error_codes/error_codes/E0178.md
Original file line number Diff line number Diff line change
@@ -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!
}
```

Expand Down

0 comments on commit d6b7b17

Please sign in to comment.