-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: resolve doc path from parent module if outer comments exist on module #19507
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
base: master
Are you sure you want to change the base?
Conversation
4db0156
to
de69c73
Compare
crates/hir-expand/src/attrs.rs
Outdated
@@ -211,6 +215,15 @@ pub struct Attr { | |||
pub path: Interned<ModPath>, | |||
pub input: Option<Box<AttrInput>>, | |||
pub ctxt: SyntaxContext, | |||
pub place: AttrPlacement, |
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 grows attributes by 8
bytes which will be noticable, we'll need to avoid that somehow if we can. Note quite sure how yet. Probably by using one of the AttrId
bits (we already do something there for cfg_attr but that is not really used so we can replace that with this likely). Will write oiut better instructions later
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.
rust-analyzer/crates/hir-expand/src/attrs.rs
Lines 185 to 189 in 588948f
impl AttrId { | |
const CFG_ATTR_BITS: usize = 7; | |
const AST_INDEX_MASK: usize = 0x00FF_FFFF; | |
const AST_INDEX_BITS: usize = Self::AST_INDEX_MASK.count_ones() as usize; | |
const CFG_ATTR_SET_BITS: u32 = 1 << 31; |
Right, that means AttrId currently uses bits like this:
- Bit 31 → is_cfg_attr
- Bits 24–30 → cfg_attr_index (7 bits)
- Bits 0–23 → ast_index (24 bits)
So, we could either remove or reduce the size of cfg_attr_index
, and reuse the freed bit for placement information.
- Bit 31 → inner_or_outer
- Bits 24–30 → (unused)or (is_cfg_attr & cfg_attr_index(6bit))
- Bits 0–23 → ast_index
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.
rust-analyzer/crates/hir-expand/src/attrs.rs
Lines 108 to 110 in 588948f
let mut it = it.clone(); | |
it.id.id = (it.id.ast_index() as u32 + last_ast_index) | |
| ((it.id.cfg_attr_index().unwrap_or(0) as u32) |
And cfg_attr
was accessed through cfg_attr_index()
but this function was only used to copy it when creating a new [Attr]
. So would we remove cfg_attr?
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.
IF the cfg attr stuff isnt actually used then lets remove it yes. Then just use the most significant bit for encoding the "inner-ness"
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.
I see. The inner-ness uses the most significant bit, and bits 24–30 are currently unused.
de69c73
to
a3167ad
Compare
…rom cfg_attr bit to doc_place bit Signed-off-by: Hayashi Mikihiro <[email protected]>
a3167ad
to
83000f5
Compare
fix: #19506

#19471
I set placement information about inner or outer in attribute.
When I check link on module, I search from parent module if attribute of doc item have a outer comment.