-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Make ModuleId
a tracked struct
#20001
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
52a4e61
to
77894b3
Compare
@@ -474,7 +521,6 @@ fn outer() { | |||
tests: t | |||
|
|||
block scope::tests | |||
name: _ |
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 one of the bugs. name
is not visible from here
77894b3
to
0f33ae9
Compare
What's the second bug? |
0f33ae9
to
2e64e8f
Compare
@@ -4437,7 +4436,7 @@ impl Impl { | |||
MacroCallKind::Derive { ast_id, derive_attr_index, derive_index, .. } => { | |||
let module_id = self.id.lookup(db).container; | |||
( | |||
crate_def_map(db, module_id.krate())[module_id.local_id] |
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.
Ah sorry. This is the second one. We were potentially using a local id of a block def map for the crate def map here.
2e64e8f
to
caefec5
Compare
caefec5
to
623b670
Compare
@@ -53,7 +53,7 @@ | |||
<span class="macro public">foo</span><span class="macro_bang">!</span><span class="parenthesis">(</span><span class="struct declaration macro public">Bar</span><span class="parenthesis">)</span><span class="semicolon">;</span> | |||
<span class="keyword">fn</span> <span class="function declaration">func</span><span class="parenthesis">(</span><span class="punctuation">_</span><span class="colon">:</span> <span class="module">y</span><span class="operator">::</span><span class="struct public">Bar</span><span class="parenthesis">)</span> <span class="brace">{</span> | |||
<span class="keyword">mod</span> <span class="module declaration">inner</span> <span class="brace">{</span> | |||
<span class="keyword">struct</span> <span class="struct declaration">Innerest</span><span class="angle"><</span><span class="keyword const">const</span> <span class="const_param const declaration">C</span><span class="colon">:</span> <span class="unresolved_reference">usize</span><span class="angle">></span> <span class="brace">{</span> <span class="field declaration">field</span><span class="colon">:</span> <span class="bracket">[</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span> <span class="brace">{</span><span class="const_param const">C</span><span class="brace">}</span><span class="bracket">]</span> <span class="brace">}</span> | |||
<span class="keyword">struct</span> <span class="struct declaration">Innerest</span><span class="angle"><</span><span class="keyword const">const</span> <span class="const_param const declaration">C</span><span class="colon">:</span> <span class="unresolved_reference">usize</span><span class="angle">></span> <span class="brace">{</span> <span class="field declaration">field</span><span class="colon">:</span> <span class="bracket">[</span><span class="unresolved_reference">u32</span><span class="semicolon">;</span> <span class="brace">{</span><span class="const_param const">C</span><span class="brace">}</span><span class="bracket">]</span><span class="comma">,</span> <span class="field declaration">field2</span><span class="colon">:</span> <span class="punctuation">&</span><span class="struct">Innerest</span> <span class="brace">}</span> |
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.
There is a bug here, primtiives don't resolve correctly in modules within blocks
8c1ea13
to
eae79c3
Compare
eae79c3
to
362ef27
Compare
So this does increase memory usage by ~30mb 😕 I am not entirely sure why though I guess we have a lot of block def map queries, and us recording tracked structs in those now makes their memo's allocate the extra slot which is what is observable here? IO would've expected the |
This is in part an experiment.
I am partially hoping for this to have a positive memory impact (as it shrinksit did not sadge. Funnily enough I also revealed 2 bugs with this (and fixed them).ModuleId
from 12 to 4 bytes)