-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Do not collect tokens for doc comments #78782
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit 209c152a7c8a212c1edaa562db7270e7829da760 with merge 7dcbd145ebb5dcf64e4f6b51c333208da42c56d7... |
See also #60930 and issues/PRs linked to it, that's how we made doc comments almost as cheap as plain comments. Recent token collection changes turned out to be a regression from that state. |
☀️ Try build successful - checks-actions |
Queued 7dcbd145ebb5dcf64e4f6b51c333208da42c56d7 with parent b1d9f31, future comparison URL. |
Finished benchmarking try commit (7dcbd145ebb5dcf64e4f6b51c333208da42c56d7): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
r=me once #78712 lands, and this is updated to call |
209c152
to
12de1e8
Compare
@bors r=Aaron1011 |
📌 Commit 12de1e8 has been approved by |
⌛ Testing commit 12de1e8 with merge 2228bc15ce0de4da8260d0b0a63f0eb1f85fe1a9... |
💔 Test failed - checks-actions |
@bors retry |
⌛ Testing commit 12de1e8 with merge fffe6ad56a1d04e9c54a1085a47f2f730e01f6b6... |
💔 Test failed - checks-actions |
⌛ Testing commit 12de1e8 with merge 6fbdeeb3268e0e28019c13d56861a5ed43c990be... |
💥 Test timed out |
@bors retry |
☀️ Test successful - checks-actions |
Do not collect tokens for doc comments Doc comment is a single token and AST has all the information to re-create it precisely. Doc comments are also responsible for majority of calls to `collect_tokens` (with `num_calls == 1` and `num_calls == 0`, cc rust-lang#78736). (I also moved token collection into `fn parse_attribute` to deduplicate code a bit.) r? `@Aaron1011`
pub fn parse_attribute(&mut self, permit_inner: bool) -> PResult<'a, ast::Attribute> { | ||
debug!("parse_attribute: permit_inner={:?} self.token={:?}", permit_inner, self.token); | ||
let inner_parse_policy = | ||
if permit_inner { InnerAttrPolicy::Permitted } else { DEFAULT_INNER_ATTR_FORBIDDEN }; | ||
self.parse_attribute_with_inner_parse_policy(inner_parse_policy) | ||
} |
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.
@petrochenkov - we were utilizing this function on the rustfmt side because we do some special case parsing with cfg_if macros to ensure we can properly format out of line mods imported within cfg_if blocks. We've got a broken toolstate (#79407) that will require we bump the rustc-ap crates within rustfmt, and doing so will pull in this change that is breaking for us.
At least as a tactical workaround, would it be alright with you if I opened a PR that added back a public helper/wrapper function we could consume, or alternatively one that made the new parse_attribute
function public along with InnerAttrPolicy
?
Definitely open to any alternatives as well!
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.
@calebcartwright
Yes, feel free to make parse_attribute
and InnerAttrPolicy
public if rustfmt needs it.
…rochenkov rustc_parse: restore public visibility on parse_attribute Make `parse_attribute` public as rustfmt is a downstream consumer. Refs rust-lang#78782 (comment) r? `@petrochenkov`
Doc comment is a single token and AST has all the information to re-create it precisely.
Doc comments are also responsible for majority of calls to
collect_tokens
(withnum_calls == 1
andnum_calls == 0
, cc #78736).(I also moved token collection into
fn parse_attribute
to deduplicate code a bit.)r? @Aaron1011