Skip to content

Commit 9db5155

Browse files
committed
Auto merge of #16224 - Veykril:syntax-ctx, r=Veykril
fix: Fix SyntaxContextID using incorrect self IDs Follow up to #16200, there was another logical bug there.
2 parents cf52c4b + 0c3fbba commit 9db5155

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

crates/hir-expand/src/hygiene.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,16 @@ fn apply_mark_internal(
149149
transparency: Transparency,
150150
) -> SyntaxContextId {
151151
let syntax_context_data = db.lookup_intern_syntax_context(ctxt);
152-
let mut opaque = syntax_context_data.opaque;
153-
let mut opaque_and_semitransparent = syntax_context_data.opaque_and_semitransparent;
152+
let mut opaque = handle_self_ref(ctxt, syntax_context_data.opaque);
153+
let mut opaque_and_semitransparent =
154+
handle_self_ref(ctxt, syntax_context_data.opaque_and_semitransparent);
154155

155156
if transparency >= Transparency::Opaque {
156-
let parent = handle_self_ref(ctxt, opaque);
157+
let parent = opaque;
158+
// Unlike rustc, with salsa we can't prefetch the to be allocated ID to create cycles with
159+
// salsa when interning, so we use a sentinel value that effectively means the current
160+
// syntax context.
157161
let new_opaque = SyntaxContextId::SELF_REF;
158-
// But we can't just grab the to be allocated ID either as that would not deduplicate
159-
// things!
160-
// So we need a new salsa store type here ...
161162
opaque = db.intern_syntax_context(SyntaxContextData {
162163
outer_expn: call_id,
163164
outer_transparency: transparency,
@@ -168,7 +169,10 @@ fn apply_mark_internal(
168169
}
169170

170171
if transparency >= Transparency::SemiTransparent {
171-
let parent = handle_self_ref(ctxt, opaque_and_semitransparent);
172+
let parent = opaque_and_semitransparent;
173+
// Unlike rustc, with salsa we can't prefetch the to be allocated ID to create cycles with
174+
// salsa when interning, so we use a sentinel value that effectively means the current
175+
// syntax context.
172176
let new_opaque_and_semitransparent = SyntaxContextId::SELF_REF;
173177
opaque_and_semitransparent = db.intern_syntax_context(SyntaxContextData {
174178
outer_expn: call_id,

0 commit comments

Comments
 (0)