diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2023-11-14 22:36:05 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2023-11-20 23:44:37 +0000 |
| commit | 5fce361d589c870d5fd2f29ff9f0cd3b6485b5be (patch) | |
| tree | a0bba4e4d69b63c365a82cb9ea4baa69a7d8ba56 /tests | |
| parent | b7a23bc08b2cc9b1ddfac18ea2019d5150d93e0e (diff) | |
| download | rust-5fce361d589c870d5fd2f29ff9f0cd3b6485b5be.tar.gz rust-5fce361d589c870d5fd2f29ff9f0cd3b6485b5be.zip | |
Account for impl Trait in lifetime suggestion
When encountering
```rust
fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { /* */ }
```
Suggest
```rust
fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { /* */ }
```
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr index c4d156825a3..3425092366f 100644 --- a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr +++ b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr @@ -9,10 +9,10 @@ help: consider using the `'static` lifetime, but this is uncommon unless you're | LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() } | +++++++ -help: instead, you are more likely to want to change the argument to be borrowed... +help: consider introducing a named lifetime parameter | -LL | fn g(mut x: &impl Iterator<Item = &()>) -> Option<&()> { x.next() } - | + +LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ ~~~ help: ...or alternatively, to want to return an owned value | LL - fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } @@ -30,10 +30,10 @@ help: consider using the `'static` lifetime, but this is uncommon unless you're | LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() } | +++++++ -help: instead, you are more likely to want to change the argument to be borrowed... +help: consider introducing a named lifetime parameter | -LL | async fn i(mut x: &impl Iterator<Item = &()>) -> Option<&()> { x.next() } - | + +LL | async fn i<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ ~~~ help: ...or alternatively, to want to return an owned value | LL - async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } @@ -75,10 +75,10 @@ help: consider using the `'static` lifetime, but this is uncommon unless you're | LL | fn g(mut x: impl Foo) -> Option<&'static ()> { x.next() } | +++++++ -help: instead, you are more likely to want to change the argument to be borrowed... +help: consider introducing a named lifetime parameter | -LL | fn g(mut x: &impl Foo) -> Option<&()> { x.next() } - | + +LL | fn g<'a>(mut x: impl Foo) -> Option<&'a ()> { x.next() } + | ++++ ~~~ help: ...or alternatively, to want to return an owned value | LL - fn g(mut x: impl Foo) -> Option<&()> { x.next() } @@ -96,10 +96,10 @@ help: consider using the `'static` lifetime, but this is uncommon unless you're | LL | fn g(mut x: impl Foo<()>) -> Option<&'static ()> { x.next() } | +++++++ -help: instead, you are more likely to want to change the argument to be borrowed... +help: consider introducing a named lifetime parameter | -LL | fn g(mut x: &impl Foo<()>) -> Option<&()> { x.next() } - | + +LL | fn g<'a>(mut x: impl Foo<()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ help: ...or alternatively, to want to return an owned value | LL - fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() } |
