diff options
| author | David Wood <david@davidtw.co> | 2018-09-02 11:10:51 +0200 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2018-09-13 10:01:18 +0200 |
| commit | 6bf131f3f4c978b93e709533d8d7ff4cb22e4769 (patch) | |
| tree | 06bcf1af49ff5d85bca00d76ed229de9c41e1c42 /src/test/ui | |
| parent | 78b21643a85a6a7e17964889122829a89e6da593 (diff) | |
| download | rust-6bf131f3f4c978b93e709533d8d7ff4cb22e4769.tar.gz rust-6bf131f3f4c978b93e709533d8d7ff4cb22e4769.zip | |
Added help message for impl trait static constraint.
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr index 1e3e997b111..e372bd33aa2 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr @@ -11,12 +11,20 @@ error: unsatisfied lifetime constraints | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` +help: you can add a constraint to the return type to make it last less than `'static` and match 'a + | +LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } + | ^^^^^^^^^^^^^^ error: unsatisfied lifetime constraints --> $DIR/must_outlive_least_region_or_bound.rs:22:69 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` +help: you can add a constraint to the return type to make it last less than `'static` and match 'a + | +LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static + 'a { x } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsatisfied lifetime constraints --> $DIR/must_outlive_least_region_or_bound.rs:29:5 diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr index d75de81fc1c..d6b19acb86b 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr @@ -5,6 +5,10 @@ LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> { | - let's call the lifetime of this reference `'1` LL | self.x.iter().map(|a| a.0) | ^^^^^^ cast requires that `'1` must outlive `'static` +help: you can add a constraint to the return type to make it last less than `'static` and match '1 + | +LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '1 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsatisfied lifetime constraints --> $DIR/static-return-lifetime-infered.rs:21:9 @@ -13,6 +17,10 @@ LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> { | -- lifetime `'a` defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^ cast requires that `'a` must outlive `'static` +help: you can add a constraint to the return type to make it last less than `'static` and match 'a + | +LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors |
