Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit lifetimes for async fn instead of duplicating them. #91403

Merged
merged 5 commits into from
Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bless clippy test.
  • Loading branch information
cjgillot committed Feb 12, 2022
commit 289216f281b136e905aef7f3e825b35ff05fb422
1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/manual_async_fn.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ fn elided_not_bound(_: &i32) -> impl Future<Output = i32> {
async { 42 }
}

#[allow(clippy::needless_lifetimes)]
async fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> i32 { 42 }

// should be ignored
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/manual_async_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ fn elided_not_bound(_: &i32) -> impl Future<Output = i32> {
async { 42 }
}

#[allow(clippy::needless_lifetimes)]
fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> + 'a + 'b {
async { 42 }
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/manual_async_fn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ LL | fn elided(_: &i32) -> impl Future<Output = i32> + '_ { 42 }
| ~~~~~~

error: this function can be simplified using the `async fn` syntax
--> $DIR/manual_async_fn.rs:101:1
--> $DIR/manual_async_fn.rs:102:1
|
LL | fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> + 'a + 'b {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
8 changes: 7 additions & 1 deletion src/tools/clippy/tests/ui/needless_lifetimes.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ error: explicit lifetimes given in parameter types where they could be elided (o
LL | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:37:1
|
LL | async fn func<'a>(args: &[&'a str]) -> Option<&'a str> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:56:1
|
Expand Down Expand Up @@ -192,5 +198,5 @@ error: explicit lifetimes given in parameter types where they could be elided (o
LL | fn lifetime_elsewhere_provided<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 32 previous errors
error: aborting due to 33 previous errors