diff options
| author | bors <bors@rust-lang.org> | 2022-08-31 08:07:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-31 08:07:26 +0000 |
| commit | ef27641f56d8783226e8f9283c4cc533dc5534f8 (patch) | |
| tree | d990e150d65ca9f2a98de69ebf54a6e2d20ca9ae | |
| parent | e0e18cc2a78334b148b8dd4a75bb3a2c2a307556 (diff) | |
| parent | 5c0e25237c62675f7118a4a8a60985fca9afc4e4 (diff) | |
| download | rust-ef27641f56d8783226e8f9283c4cc533dc5534f8.tar.gz rust-ef27641f56d8783226e8f9283c4cc533dc5534f8.zip | |
Auto merge of #13154 - Veykril:ty-mac-expander, r=Veykril
Drop the expander borrow in all control flow paths The change in https://github.com/rust-lang/rust-analyzer/pull/13123 actually re-uses the RefMut borrow instead of dropping it so we need to drop it manually where required. Fixes https://github.com/rust-lang/rust-analyzer/issues/13153
| -rw-r--r-- | crates/hir-ty/src/lower.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs index 3f6d0844e9c..708e63d7fd3 100644 --- a/crates/hir-ty/src/lower.rs +++ b/crates/hir-ty/src/lower.rs @@ -332,7 +332,10 @@ impl<'a> TyLoweringContext<'a> { TypeRef::Macro(macro_call) => { let (mut expander, recursion_start) = { match RefMut::filter_map(self.expander.borrow_mut(), Option::as_mut) { + // There already is an expander here, this means we are already recursing Ok(expander) => (expander, false), + // No expander was created yet, so we are at the start of the expansion recursion + // and therefore have to create an expander. Err(expander) => ( RefMut::map(expander, |it| { it.insert(Expander::new( @@ -362,9 +365,14 @@ impl<'a> TyLoweringContext<'a> { .exit(self.db.upcast(), mark); Some(ty) } - _ => None, + _ => { + drop(expander); + None + } } }; + + // drop the expander, resetting it to pre-recursion state if recursion_start { *self.expander.borrow_mut() = None; } |
