-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
There was a problem hiding this 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
crates/hir_expand/src/input.rs
Outdated
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" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use known_names
instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, right!
bors r+ |
changelog skip |
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>
We now remove any
#[derive]
before and including the one we want to expand, in themacro_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)