diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-01-06 15:28:12 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-01-06 15:28:12 +0100 |
| commit | 99fda5c1cec9ab67c3da197b5679408d2e51d093 (patch) | |
| tree | 00ecbb9e05c58760452acdbf2d3b2205328b575b /src/librustc_error_codes/error_codes | |
| parent | a80e63f3fa77792e848e3b248acf4c0acda2e310 (diff) | |
| download | rust-99fda5c1cec9ab67c3da197b5679408d2e51d093.tar.gz rust-99fda5c1cec9ab67c3da197b5679408d2e51d093.zip | |
Clean up E0178 explanation
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0178.md | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/librustc_error_codes/error_codes/E0178.md b/src/librustc_error_codes/error_codes/E0178.md index 07980ad83f1..0c6f918632f 100644 --- a/src/librustc_error_codes/error_codes/E0178.md +++ b/src/librustc_error_codes/error_codes/E0178.md @@ -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! } ``` |
