From 99fda5c1cec9ab67c3da197b5679408d2e51d093 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 6 Jan 2020 15:28:12 +0100 Subject: [PATCH] Clean up E0178 explanation --- src/librustc_error_codes/error_codes/E0178.md | 25 +++++++++++++------ 1 file 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 07980ad83f1b5..0c6f918632f47 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! } ```