The + type operator was used in an ambiguous context.
Erroneous code example:
#![allow(unused)]
fn main() {
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:
#![allow(unused)]
fn main() {
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.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/error_codes/E0178.html