The following error
|
error: cannot infer an appropriate lifetime |
|
--> $DIR/must_outlive_least_region_or_bound.rs:12:69 |
|
| |
|
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } |
|
| -------------------------------- ^ ...but this borrow... |
|
| | |
|
| this return type evaluates to the `'static` lifetime... |
|
| |
|
note: ...can't outlive the lifetime `'a` as defined on the function body at 12:15 |
|
--> $DIR/must_outlive_least_region_or_bound.rs:12:15 |
|
| |
|
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } |
|
| ^^ |
|
help: you can add a bound to the return type to make it last less than `'static` and match the lifetime `'a` as defined on the function body at 12:15 |
|
| |
|
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static + 'a { x } |
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
should instead suggest changing the explicit 'static bound or not provide a suggestion at all.
Follow up to #67595.
The following error
rust/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
Lines 37 to 53 in 0731573
should instead suggest changing the explicit
'staticbound or not provide a suggestion at all.Follow up to #67595.