Expand derive invocations in left-to-right order by Aaron1011 · Pull Request #84023 · rust-lang/rust (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this.
The order of entries in the top level invocations
vector is non-significant, it's a job queue - entries can return to it if they are not ready to be resolved or expanded so the exact expansion order is unspecified in general.
So this PR changes one unpredictable order to another?
Once #[derive(Trait1, Trait2)] ITEM
produced ITEM
, placeholder(Trait1)
and placeholder(Trait2)
these three items part their ways from each other and can be expanded independently in any order (you don't need any specific order to expand them correctly).
The existing code chooses the tentative order ITEM
-> placeholder(Trait2)
-> placeholder(Trait1)
, but it may change later if invocations in ITEM
are not yet ready.
The new code chooses the tentative order placeholder(Trait1)
-> placeholder(Trait2)
-> ITEM
(which may also change, but only inside ITEM
because the two placeholders here are always ready by construction).
Am I missing anything?