Skip to content

Commit 99fda5c

Browse files
Clean up E0178 explanation
1 parent a80e63f commit 99fda5c

File tree

1 file changed

+18
-7
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+18
-7
lines changed

src/librustc_error_codes/error_codes/E0178.md

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1-
In types, the `+` type operator has low precedence, so it is often necessary
2-
to use parentheses.
1+
The `+` type operator was used in an ambiguous context.
32

4-
For example:
3+
Erroneous code example:
54

65
```compile_fail,E0178
76
trait Foo {}
87
98
struct Bar<'a> {
10-
w: &'a Foo + Copy, // error, use &'a (Foo + Copy)
11-
x: &'a Foo + 'a, // error, use &'a (Foo + 'a)
12-
y: &'a mut Foo + 'a, // error, use &'a mut (Foo + 'a)
13-
z: fn() -> Foo + 'a, // error, use fn() -> (Foo + '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!
1425
}
1526
```
1627

0 commit comments

Comments
 (0)