Skip to content

Conversation

@surechen
Copy link
Contributor

@surechen surechen commented Nov 19, 2021

Fix shadow_same's false positive for async function's params(Fixes #7915):

Example Code:

#![deny(clippy::shadow_same)]

pub async fn foo(_a: i32) {
}

Output:

error: `_a` is shadowed by itself in `_a

Hir:

pub async fn foo(_a: i32)
 ->
     /*impl Trait*/ #[lang = "from_generator"](move |mut _task_context|
                                                   {
                                                       let _a = _a;
                                                       { let _t = { }; _t }
                                                   })

Skip checking async function's params.

changelog: Fix shadow_same's false positive for async function's params

@rust-highfive
Copy link

r? @giraffate

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 19, 2021
Copy link
Contributor

@giraffate giraffate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be simpler to check DesugaringKind. This may help us:
#7174.

@surechen
Copy link
Contributor Author

It might be simpler to check DesugaringKind. This may help us: #7174.
Thank you very much. By checking [DesugaringKind] is more concise and more accurate than my method.

Fix shadow_same's positive false for async function's params:

Example Code:
```rust
#![deny(clippy::shadow_same)]

pub async fn foo(_a: i32) {
}
```
Output:
```
error: `_a` is shadowed by itself in `_a
```

Hir:
```rust
pub async fn foo(_a: i32)
 ->
     /*impl Trait*/ #[lang = "from_generator"](move |mut _task_context|
                                                   {
                                                       let _a = _a;
                                                       { let _t = { }; _t }
                                                   })
```

Skip checking async function's params.

changelog: Fix shadow_same's positive false for async function's params
@giraffate
Copy link
Contributor

@bors r+

It looks good, thanks!

@bors
Copy link
Contributor

bors commented Nov 21, 2021

📌 Commit 846c0be has been approved by giraffate

@bors
Copy link
Contributor

bors commented Nov 21, 2021

⌛ Testing commit 846c0be with merge de2208a...

@bors
Copy link
Contributor

bors commented Nov 22, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: giraffate
Pushing de2208a to master...

@bors bors merged commit de2208a into rust-lang:master Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shadow_same is just plain wrong in an async context

4 participants