Skip to content

Commit ef27641

Browse files
committed
Auto merge of #13154 - Veykril:ty-mac-expander, r=Veykril
Drop the expander borrow in all control flow paths The change in #13123 actually re-uses the RefMut borrow instead of dropping it so we need to drop it manually where required. Fixes #13153
2 parents e0e18cc + 5c0e252 commit ef27641

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/hir-ty/src/lower.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,10 @@ impl<'a> TyLoweringContext<'a> {
332332
TypeRef::Macro(macro_call) => {
333333
let (mut expander, recursion_start) = {
334334
match RefMut::filter_map(self.expander.borrow_mut(), Option::as_mut) {
335+
// There already is an expander here, this means we are already recursing
335336
Ok(expander) => (expander, false),
337+
// No expander was created yet, so we are at the start of the expansion recursion
338+
// and therefore have to create an expander.
336339
Err(expander) => (
337340
RefMut::map(expander, |it| {
338341
it.insert(Expander::new(
@@ -362,9 +365,14 @@ impl<'a> TyLoweringContext<'a> {
362365
.exit(self.db.upcast(), mark);
363366
Some(ty)
364367
}
365-
_ => None,
368+
_ => {
369+
drop(expander);
370+
None
371+
}
366372
}
367373
};
374+
375+
// drop the expander, resetting it to pre-recursion state
368376
if recursion_start {
369377
*self.expander.borrow_mut() = None;
370378
}

0 commit comments

Comments
 (0)