mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 14:33:29 +00:00
commit
ca4e10b7fc
1 changed files with 17 additions and 19 deletions
|
@ -6,7 +6,7 @@
|
||||||
//!
|
//!
|
||||||
//! This usually involves resolving names, collecting generic arguments etc.
|
//! This usually involves resolving names, collecting generic arguments etc.
|
||||||
use std::{
|
use std::{
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell, RefMut},
|
||||||
iter,
|
iter,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
@ -330,26 +330,26 @@ impl<'a> TyLoweringContext<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TypeRef::Macro(macro_call) => {
|
TypeRef::Macro(macro_call) => {
|
||||||
let (expander, recursion_start) = {
|
let (mut expander, recursion_start) = {
|
||||||
let mut expander = self.expander.borrow_mut();
|
match RefMut::filter_map(self.expander.borrow_mut(), Option::as_mut) {
|
||||||
if expander.is_some() {
|
Ok(expander) => (expander, false),
|
||||||
(Some(expander), false)
|
Err(expander) => (
|
||||||
} else {
|
RefMut::map(expander, |it| {
|
||||||
*expander = Some(Expander::new(
|
it.insert(Expander::new(
|
||||||
self.db.upcast(),
|
self.db.upcast(),
|
||||||
macro_call.file_id,
|
macro_call.file_id,
|
||||||
self.resolver.module(),
|
self.resolver.module(),
|
||||||
));
|
))
|
||||||
(Some(expander), true)
|
}),
|
||||||
|
true,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let ty = if let Some(mut expander) = expander {
|
let ty = {
|
||||||
let expander_mut = expander.as_mut().unwrap();
|
|
||||||
let macro_call = macro_call.to_node(self.db.upcast());
|
let macro_call = macro_call.to_node(self.db.upcast());
|
||||||
match expander_mut.enter_expand::<ast::Type>(self.db.upcast(), macro_call) {
|
match expander.enter_expand::<ast::Type>(self.db.upcast(), macro_call) {
|
||||||
Ok(ExpandResult { value: Some((mark, expanded)), .. }) => {
|
Ok(ExpandResult { value: Some((mark, expanded)), .. }) => {
|
||||||
let ctx =
|
let ctx = LowerCtx::new(self.db.upcast(), expander.current_file_id());
|
||||||
LowerCtx::new(self.db.upcast(), expander_mut.current_file_id());
|
|
||||||
let type_ref = TypeRef::from_ast(&ctx, expanded);
|
let type_ref = TypeRef::from_ast(&ctx, expanded);
|
||||||
|
|
||||||
drop(expander);
|
drop(expander);
|
||||||
|
@ -364,8 +364,6 @@ impl<'a> TyLoweringContext<'a> {
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
};
|
||||||
if recursion_start {
|
if recursion_start {
|
||||||
*self.expander.borrow_mut() = None;
|
*self.expander.borrow_mut() = None;
|
||||||
|
|
Loading…
Reference in a new issue