-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Coalescing for line doc comments #60936
Comments
It cannot be interpreted that way because
so we don’t need the |
I've just checked, In other words, the details need to be figured out. |
Another incompatibility is with code doing something like this
(Again, we'll need crater to figure out whether we need to provide a compatibility layer or not.) |
Interesting. I tried to run |
A bit on representing tokens produced by lexer losslessly (TLDR: I think literals do it right). Tokens need to contain their kind and data - The same logic is applicable to doc comments, which are basically raw string literals with unusual quotes (
(the original token still can be losslessly recovered). If you look at line doc comments like that, it's kind of clear why each line is a separate token. Keeping them separate at token level, but then concatenating later kind of defeats the purpose of optimization (it may be more work, and more interned strings).
(the original token still can be losslessly recovered). Pretty weird. |
I would have thought it would be this:
Here |
That's very unfortunate, if it means that It's worth noting that if we converted every multi-line |
It seems like one avenue is to have some crate-level flag or so (maybe just a feature) that collapses doc comments -- at least for now, it'd be basically internal-use-only but if that makes core/std smaller and faster to decode that's already a pretty good win. Eventually we could presumably edition-gate this change in some way (though the interaction with macros might make that a bit hard). |
Cheaper doc comments This PR implements the idea from #60935: represent doc comments more cheaply, rather than converting them into `#[doc="..."]` attribute form. Unlike #60936 (which is about coalescing doc comments to reduce their number), this approach does not have any backwards compatibility concerns, and it eliminates about 80-90% of the current cost of doc comments (as estimated using the numbers in #60930, which eliminated the cost of doc comments entirely by treating them as normal comments). r? @petrochenkov
Right now multiple line doc comments are considered separate tokens and separate attributes:
is interpreted as
To mitigate the perf impact from turning normal comments into doc comments (#60930) we may want to merge multi-line line comments into a single token and a single attribute:
The text was updated successfully, but these errors were encountered: