Rollup merge of #69188 - GuillaumeGomez:clean-up-e0309, r=Dylan-DPC
Clean up E0309 explanation r? @Dylan-DPC
This commit is contained in:
commit
cc497c4c84
1 changed files with 13 additions and 9 deletions
|
@ -1,9 +1,7 @@
|
||||||
The type definition contains some field whose type
|
A parameter type is missing an explicit lifetime bound and may not live long
|
||||||
requires an outlives annotation. Outlives annotations
|
enough.
|
||||||
(e.g., `T: 'a`) are used to guarantee that all the data in T is valid
|
|
||||||
for at least the lifetime `'a`. This scenario most commonly
|
Erroneous code example:
|
||||||
arises when the type contains an associated type reference
|
|
||||||
like `<T as SomeTrait<'a>>::Output`, as shown in this example:
|
|
||||||
|
|
||||||
```compile_fail,E0309
|
```compile_fail,E0309
|
||||||
// This won't compile because the applicable impl of
|
// This won't compile because the applicable impl of
|
||||||
|
@ -25,9 +23,15 @@ where
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Here, the where clause `T: 'a` that appears on the impl is not known to be
|
The type definition contains some field whose type requires an outlives
|
||||||
satisfied on the struct. To make this example compile, you have to add
|
annotation. Outlives annotations (e.g., `T: 'a`) are used to guarantee that all
|
||||||
a where-clause like `T: 'a` to the struct definition:
|
the data in T is valid for at least the lifetime `'a`. This scenario most
|
||||||
|
commonly arises when the type contains an associated type reference like
|
||||||
|
`<T as SomeTrait<'a>>::Output`, as shown in the previous code.
|
||||||
|
|
||||||
|
There, the where clause `T: 'a` that appears on the impl is not known to be
|
||||||
|
satisfied on the struct. To make this example compile, you have to add a
|
||||||
|
where-clause like `T: 'a` to the struct definition:
|
||||||
|
|
||||||
```
|
```
|
||||||
struct Foo<'a, T>
|
struct Foo<'a, T>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue