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

Rewrite #[derive] removal code to be based on AST #8443

Merged
merged 6 commits into from
Apr 9, 2021
Merged

Rewrite #[derive] removal code to be based on AST #8443

merged 6 commits into from
Apr 9, 2021

Conversation

jonas-schievink
Copy link
Contributor

We now remove any #[derive] before and including the one we want to expand, in the macro_arg query.

The same infra will be needed by attribute macros (except we only remove the attribute we're expanding, not any preceding ones).

Part of #8434 (doesn't implement the cfg-expansion yet, because that's more difficult)

Copy link
Member

@edwin0cheng edwin0cheng left a comment

Choose a reason for hiding this comment

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

LGTM, just a little nit

if let Some(name) =
attr.path().and_then(|path| path.as_single_segment()).and_then(|seg| seg.name_ref())
{
if name.as_name().to_string() == "derive" {
Copy link
Member

Choose a reason for hiding this comment

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

use known_names instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, right!

@jonas-schievink
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 9, 2021

@bors bors bot merged commit 3b1692c into rust-lang:master Apr 9, 2021
@jonas-schievink jonas-schievink deleted the strip-derives branch April 9, 2021 13:02
@lnicola
Copy link
Member

lnicola commented Apr 12, 2021

changelog skip

bors bot added a commit that referenced this pull request May 11, 2021
8796: internal: rewrite `#[derive]` removal to be based on AST (take 2) r=jonas-schievink a=jonas-schievink

Second attempt of #8443, this uses syntactical attribute offsets in `hir_expand`, and changes `attr.rs` to make those easy to derive.

This will make it easy to add similar attribute removal for attribute macros, unblocking them.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
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.

3 participants