]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/static-return-lifetime-infered.stderr
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / impl-trait / static-return-lifetime-infered.stderr
1 error: cannot infer an appropriate lifetime
2   --> $DIR/static-return-lifetime-infered.rs:17:16
3    |
4 LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
5    |                                   ----------------------- this return type evaluates to the `'static` lifetime...
6 LL |         self.x.iter().map(|a| a.0)
7    |         ------ ^^^^
8    |         |
9    |         ...but this borrow...
10    |
11 note: ...can't outlive the anonymous lifetime #1 defined on the method body at 16:5
12   --> $DIR/static-return-lifetime-infered.rs:16:5
13    |
14 LL | /     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
15 LL | |         self.x.iter().map(|a| a.0)
16 LL | |     }
17    | |_____^
18 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
19    |
20 LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
21    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22
23 error: cannot infer an appropriate lifetime
24   --> $DIR/static-return-lifetime-infered.rs:21:16
25    |
26 LL |     fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
27    |                                     ----------------------- this return type evaluates to the `'static` lifetime...
28 LL |         self.x.iter().map(|a| a.0)
29    |         ------ ^^^^
30    |         |
31    |         ...but this borrow...
32    |
33 note: ...can't outlive the lifetime 'a as defined on the method body at 20:20
34   --> $DIR/static-return-lifetime-infered.rs:20:20
35    |
36 LL |     fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
37    |                    ^^
38 help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime 'a as defined on the method body at 20:20
39    |
40 LL |     fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
41    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42
43 error: aborting due to 2 previous errors
44