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

Forward attributes on impl function parameters to variable declaration. #227

Merged

Conversation

azriel91
Copy link
Contributor

@azriel91 azriel91 commented Jan 6, 2023

Fixes #226.

It feels rare to have attributes on parameters, I can't imagine a concrete scenario where forwarding all attributes is undesirable.
We could filter the attributes that are forwarded to only the #[cfg(..)] ones.

quote!(
#(#attrs)*
let #mutability #ident = #ident;
)
}
} else {
let pat = &arg.pat;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to hit this branch -- I tried using a DeconstructedStruct { value } but it didn't parse.

Presumably the same attribute forwarding needs to be done here as well

Copy link
Owner

Choose a reason for hiding this comment

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

Try #[cfg(any())] _: T or #[cfg(any())] (a, b): (T, T)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool thanks, managed to simplify the test case

@azriel91 azriel91 force-pushed the bugfix/226/forward-param-attributes branch from 3cb7599 to 6cf682f Compare January 6, 2023 06:43
@azriel91 azriel91 requested a review from dtolnay January 6, 2023 17:19
Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks!

@dtolnay dtolnay merged commit 2866cb9 into dtolnay:master Jan 6, 2023
@azriel91 azriel91 deleted the bugfix/226/forward-param-attributes branch January 6, 2023 22:57
crapStone added a commit to Calciumdibromid/CaBr2 that referenced this pull request Jan 9, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [async-trait](https://github.com/dtolnay/async-trait) | dependencies | patch | `0.1.60` -> `0.1.61` |

---

### Release Notes

<details>
<summary>dtolnay/async-trait</summary>

### [`v0.1.61`](https://github.com/dtolnay/async-trait/releases/tag/0.1.61)

[Compare Source](dtolnay/async-trait@0.1.60...0.1.61)

-   Fix async function signatures that involve #\[cfg(...)] attributes on parameters ([#&#8203;227](dtolnay/async-trait#227), thanks [@&#8203;azriel91](https://github.com/azriel91))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC44NC4xIiwidXBkYXRlZEluVmVyIjoiMzQuOTMuMCJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Co-authored-by: crapStone <crapstone01@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1707
Reviewed-by: crapStone <crapstone@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attributes on impl parameters are not forwarded to body
2 participants