mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 17:28:09 +00:00
Fix block inner item defined in macro
This commit is contained in:
parent
75011bbccb
commit
6a3f2ce76c
2 changed files with 32 additions and 0 deletions
|
@ -174,6 +174,12 @@ impl Ctx {
|
|||
let forced_vis = self.forced_visibility.take();
|
||||
|
||||
let mut block_stack = Vec::new();
|
||||
|
||||
// if container itself is block, add it to the stack
|
||||
if let Some(block) = ast::BlockExpr::cast(container.clone()) {
|
||||
block_stack.push(self.source_ast_id_map.ast_id(&block));
|
||||
}
|
||||
|
||||
for event in container.preorder().skip(1) {
|
||||
match event {
|
||||
WalkEvent::Enter(node) => {
|
||||
|
|
|
@ -372,6 +372,32 @@ fn recursive_inner_item_macro_rules() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_macro_defining_block_with_items() {
|
||||
check_infer(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
() => {{
|
||||
fn bar() -> usize { 0 }
|
||||
bar()
|
||||
}};
|
||||
}
|
||||
fn main() {
|
||||
let _a = foo!();
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
!15..18 '{0}': usize
|
||||
!16..17 '0': usize
|
||||
!0..24 '{fnbar...bar()}': usize
|
||||
!18..21 'bar': fn bar() -> usize
|
||||
!18..23 'bar()': usize
|
||||
98..122 '{ ...!(); }': ()
|
||||
108..110 '_a': usize
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_type_value_macro_having_same_name() {
|
||||
check_infer(
|
||||
|
|
Loading…
Reference in a new issue