Proposal
Move "trivial" (no-op) implementations of TypeFoldable and TypeVisitable from macro-by-example (currently rustc_middle::macros::TrivialTypeTraversalImpls into the existing derive macros when a new attribute (such as #[contains_nothing_interesting_for_traversers], still subject to bike-shedding) is present.
This work has already been undertaken as part of rust-lang/rust#108214—but because inappropriate use of that attribute will generate impls that are erroneously no-ops, I think (though I'm far from certain) it could result in unsoundness. Accordingly, @RalfJung was rightly concerned that this change is not without risk and for that reason I thought an MCP may be wise.
For historical context, the existing TrivialTypeTraversalImpls macro started out as CopyImpls in 8403b82. The current comment that types need implement Copy appears to be a hangover from that, and ceased being relevant when folding was changed to take self by value in rust-lang/rust#78313; the comment that they must not care (sic) arena allocated data is more relevant, but I think it is more correct to say they must not transitively contain types that may be of interest to folders/visitors: other arena-allocated data is irrelevant, and those interesting types would not cease being interesting if they were no longer arena-allocated.
Mentors or Reviewers
The implementing PR itself was not motivated by this change, but rather by a move to generalise such no-op implementations over the interner. This was suggested to me by @oli-obk, who I therefore already nominated as the reviewer for the PR.
Process
The main points of the Major Change Process are as follows:
You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
Proposal
Move "trivial" (no-op) implementations of
TypeFoldableandTypeVisitablefrom macro-by-example (currentlyrustc_middle::macros::TrivialTypeTraversalImplsinto the existing derive macros when a new attribute (such as#[contains_nothing_interesting_for_traversers], still subject to bike-shedding) is present.This work has already been undertaken as part of rust-lang/rust#108214—but because inappropriate use of that attribute will generate impls that are erroneously no-ops, I think (though I'm far from certain) it could result in unsoundness. Accordingly, @RalfJung was rightly concerned that this change is not without risk and for that reason I thought an MCP may be wise.
For historical context, the existing
TrivialTypeTraversalImplsmacro started out asCopyImplsin8403b82. The current comment that types need implementCopyappears to be a hangover from that, and ceased being relevant when folding was changed to takeselfby value in rust-lang/rust#78313; the comment that they must not care (sic) arena allocated data is more relevant, but I think it is more correct to say they must not transitively contain types that may be of interest to folders/visitors: other arena-allocated data is irrelevant, and those interesting types would not cease being interesting if they were no longer arena-allocated.Mentors or Reviewers
The implementing PR itself was not motivated by this change, but rather by a move to generalise such no-op implementations over the interner. This was suggested to me by @oli-obk, who I therefore already nominated as the reviewer for the PR.
Process
The main points of the Major Change Process are as follows:
@rustbot second.-C flag, then full team check-off is required.@rfcbot fcp mergeon either the MCP or the PR.You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.