-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Move doc-comment highlight injection from AST to HIR #8059
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
Conversation
changelog internal Support cfg_attr in doc-comment syntax highlighting |
match comment.text().find(RUSTDOC_FENCE) { | ||
let mut string; | ||
for attr in attributes.by_key("doc").attrs() { | ||
let src = attr.to_src(&owner); |
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.
This to_src
call actually has O(n^2) runtime as it recollects all doc items every call then takes the nth item from there, should probably look into a better mapping
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.
Yeah, I'm pretty unsure what would make a good API for attributes. Let me know if you have ideas.
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.
Yeah, most of our .source
calls are quadratic. The fundamental thing here is that we can't ask for sources of a single thing. Rather, we can ask the parent "what are the sources of all your children?", and there needs to be some caching layer there. impl HasSource for Variant
is also quadratic, for example, and that's not really right.
Ideally, this caching should be done transparently by salsa, but this is the bit where we need gc unfortunately.
}, | ||
// #[cfg_attr(..., doc = "", ...)] | ||
None => { | ||
// We gotta hunt the string token manually here |
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.
This is also something I'd love to fix with a better attributes API
match comment.text().find(RUSTDOC_FENCE) { | ||
let mut string; | ||
for attr in attributes.by_key("doc").attrs() { | ||
let src = attr.to_src(&owner); |
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.
Yeah, most of our .source
calls are quadratic. The fundamental thing here is that we can't ask for sources of a single thing. Rather, we can ask the parent "what are the sources of all your children?", and there needs to be some caching layer there. impl HasSource for Variant
is also quadratic, for example, and that's not really right.
Ideally, this caching should be done transparently by salsa, but this is the bit where we need gc unfortunately.
bors r=matklad,jonas-schievink |
Fixes #5016