]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0227.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0227.md
1 This error indicates that the compiler is unable to determine whether there is
2 exactly one unique region in the set of derived region bounds.
3
4 Example of erroneous code:
5
6 ```compile_fail,E0227
7 trait Foo<'foo>: 'foo {}
8 trait Bar<'bar>: 'bar {}
9
10 trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {}
11
12 struct Baz<'foo, 'bar> {
13     baz: dyn FooBar<'foo, 'bar>,
14 }
15 ```
16
17 Here, `baz` can have either `'foo` or `'bar` lifetimes.
18
19 To resolve this error, provide an explicit lifetime:
20
21 ```rust
22 trait Foo<'foo>: 'foo {}
23 trait Bar<'bar>: 'bar {}
24
25 trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {}
26
27 struct Baz<'foo, 'bar, 'baz>
28 where
29     'baz: 'foo + 'bar,
30 {
31     obj: dyn FooBar<'foo, 'bar> + 'baz,
32 }
33 ```