-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
expand: Refactor InvocationCollector visitor for better code reuse #92573
Conversation
} | ||
fn take_mac_call(self) -> (ast::MacCall, Self::AttrsTy, bool) { | ||
unreachable!() | ||
} |
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.
Initially I tried the fn take_mac_call(self) -> Result<...>
approach, but it ended up being less convenient than two separate functions due to consuming self
too early (we don't want self
to be consumed if there's no macro call).
.field("tag", &self.tag) | ||
.finish() | ||
} | ||
} |
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.
Deriving this impl puts the Debug
requirement on tag types, unfortunately.
ast: Always keep a `NodeId` in `ast::Crate` This makes it more uniform with other expanded nodes. It makes generic code in rust-lang#92573 simpler in particular. This is another follow-up to rust-lang#91313. r? `@Aaron1011`
Updated. |
r=me with the commits squashed |
Other commits are separate small refactorings that are weakly related to the main commit "Refactor InvocationCollector visitor", they also touch some code other than invocation collector, so I think it's reasonable to keep them separate. |
📌 Commit 4523466 has been approved by |
…askrgr Rollup of 8 pull requests Successful merges: - rust-lang#92055 (Add release notes for 1.58) - rust-lang#92490 (Move crate drop-down to search results page) - rust-lang#92510 (Don't resolve blocks in foreign functions) - rust-lang#92573 (expand: Refactor InvocationCollector visitor for better code reuse) - rust-lang#92608 (rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes) - rust-lang#92657 (Implemented const casts of raw pointers) - rust-lang#92671 (Make `Atomic*::from_mut` return `&mut Atomic*`) - rust-lang#92673 (Remove useless collapse toggle on "all items" page) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The refactoring part of #92473.
Invocation collector visitor logic now lives in two main functions:
fn flat_map_node
, corresponding to "one to many" expansionsfn visit_node
, corresponding to "one to one" expansionsAll specific mut visitor methods now use one of these functions.
The new
InvocationCollectorNode
trait implemented for allAstFragment
nodes provides the necessary small pieces of functionality required to implement the(flat_map,visit)_node
functions.r? @Aaron1011