Remove unused rules from extension_trait
macro
#1004
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
as part of the initiative to improve compile times we've been looking at rustc benchmarks over a number of crates in the ecosystem.
We've noticed
async-std
was exercising rustc's macro expansion in surprising ways, and we're currently working on improving this part of the compiler. In the meantime, we thought we'd try to help by (hopefully) improving theextension_trait
macro:@doc
and@ext
contexts. However, a redundant rule handling a single lifetime remains, adding overhead to macro expansion: the one in the@ext
context costs around 20% of thecheck
time.By removing the unused rules, the compile time gains in builds of
async-std
itself (i.e. in regular day-to-day development, when dependencies are already built) are around 19-20% for acheck
build, 16% in debug builds, and 6-7% in release builds; it's expected that downstream crates could also see some improvements to compile times (butasync-std
is not that heavy to build in the first place) when they build their own dependencies: fresh checkouts or after a cargo clean, after a rustc update, after changingRUSTFLAGS
, etc.I'm opening this as a draft PR because I'm not sure this a correct fix. The original macro was fixed a couple years ago in #405, and these two rules remained: it's not clear to me in which cases the fake
impl Future
can or cannot borrow from its environment, making the innermod borrowed
andmod owned
differentiation unused, and therefore making we wonder whether they can actually be removed wholesale or if the old fix was somehow incomplete ?That being said, this PR seems to be indeed doing the same things as before, both for compilation and documentation, which is reassuring.