summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0178.md
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0178.md')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0178.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0178.md b/compiler/rustc_error_codes/src/error_codes/E0178.md
new file mode 100644
index 000000000..0c6f91863
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0178.md
@@ -0,0 +1,30 @@
+The `+` type operator was used in an ambiguous context.
+
+Erroneous code example:
+
+```compile_fail,E0178
+trait Foo {}
+
+struct Bar<'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!
+}
+```
+
+More details can be found in [RFC 438].
+
+[RFC 438]: https://github.com/rust-lang/rfcs/pull/438