diff options
| author | bors <bors@rust-lang.org> | 2018-06-28 03:57:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-06-28 03:57:28 +0000 |
| commit | ba196bdcb10736da5d14c961bd8962d80e300913 (patch) | |
| tree | bf3b38bcf15b9d776031b961e7640cb9d751925e /src/test/incremental/thinlto | |
| parent | 99a9d6806d355b69fa66621df5208342de823aea (diff) | |
| parent | 612657d9f0b158f0b78e85e3f0a694ddcbf83268 (diff) | |
| download | rust-ba196bdcb10736da5d14c961bd8962d80e300913.tar.gz rust-ba196bdcb10736da5d14c961bd8962d80e300913.zip | |
Auto merge of #51444 - estebank:impl-static, r=nikomatsakis
Suggestion for 'static impl Trait return
When encountering a named or anonymous sup requirement (for example,
`&'a self`) and a `'static` impl Trait return type, suggest adding the
`'_` lifetime constraing to the return type.
Fix #43719, #51282.
```
error: cannot infer an appropriate lifetime
--> $DIR/static-return-lifetime-infered.rs:17:16
|
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
| ----------------------- this return type evaluates to the `'static` lifetime...
LL | self.x.iter().map(|a| a.0)
| ------ ^^^^
| |
| ...but this borrow...
|
note: ...can't outlive the anonymous lifetime #1 defined on the method body at 16:5
--> $DIR/static-return-lifetime-infered.rs:16:5
|
LL | / fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
LL | | self.x.iter().map(|a| a.0)
LL | | }
| |_____^
help: you can add a constraint to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the method body at 16:5
|
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions
