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

Propagate allows to auto-generated impls #393

Closed

Conversation

wprzytula
Copy link

@wprzytula wprzytula commented Dec 6, 2024

As noted in #392, built-in derive macros propagate allow attributes to auto-generated impl blocks. For consistency, the same is done for thiserror::Error derive macro.

Note for reviewers: I might have omitted some places where propagation should be done.

Fixes: #392

As noted in dtolnay#392, built-in derive macros propagate `allow` attributes
to auto-generated `impl` blocks. For consistency, the same is done for
`thiserror::Error` derive macro.
// }
// }
// ```
attrs.allows = Some(attr);
Copy link
Owner

Choose a reason for hiding this comment

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

This would drop all but the last allow attribute. When there are multiple attributes, the expected behavior would be that they all make it to the impl, not just the last one.

Copy link
Author

Choose a reason for hiding this comment

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

You're right; the only scenario I considered was and tested was with all allows listed in one attribute.

@@ -115,6 +117,30 @@ pub fn get(input: &[Attribute]) -> Result<Attrs> {
original: attr,
span,
});
} else if attr.path().is_ident("allow") {
Copy link
Owner

Choose a reason for hiding this comment

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

derive(Debug) propagates some other attributes. I didn't track down exactly which ones but I tested with warn.

@dtolnay
Copy link
Owner

dtolnay commented Dec 6, 2024

Thanks for the PR!

Let's solve the original issue with deprecation a different way as pointed out in #392 (comment).

@dtolnay dtolnay closed this Dec 6, 2024
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.

allows are not propagated to auto-generated impls
2 participants