Error code E0227

This error indicates that the compiler is unable to determine whether there is exactly one unique region in the set of derived region bounds.

Example of erroneous code:

trait Foo<'foo>: 'foo {}
trait Bar<'bar>: 'bar {}

trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {}

struct Baz<'foo, 'bar> {
    baz: dyn FooBar<'foo, 'bar>,
}
Run

Here, baz can have either 'foo or 'bar lifetimes.

To resolve this error, provide an explicit lifetime:

trait Foo<'foo>: 'foo {}
trait Bar<'bar>: 'bar {}

trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {}

struct Baz<'foo, 'bar, 'baz>
where
    'baz: 'foo + 'bar,
{
    obj: dyn FooBar<'foo, 'bar> + 'baz,
}
Run

Back to list of error codes