mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-03 13:13:18 +00:00 
			
		
		
		
	hir_def: ignore ast::Type in file_item_tree query
This commit is contained in:
		
							parent
							
								
									28ef7c20d7
								
							
						
					
					
						commit
						14918a3870
					
				@ -104,6 +104,11 @@ impl ItemTree {
 | 
				
			|||||||
                    // items and expanded during block DefMap computation
 | 
					                    // items and expanded during block DefMap computation
 | 
				
			||||||
                    return Default::default();
 | 
					                    return Default::default();
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
 | 
					                ast::Type(_ty) => {
 | 
				
			||||||
 | 
					                    // FIXME: This occurs because macros in type position are treated as inner
 | 
				
			||||||
 | 
					                    // items and expanded during block DefMap computation
 | 
				
			||||||
 | 
					                    return Default::default();
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
                ast::Expr(e) => {
 | 
					                ast::Expr(e) => {
 | 
				
			||||||
                    // Macros can expand to expressions. We return an empty item tree in this case, but
 | 
					                    // Macros can expand to expressions. We return an empty item tree in this case, but
 | 
				
			||||||
                    // still need to collect inner items.
 | 
					                    // still need to collect inner items.
 | 
				
			||||||
 | 
				
			|||||||
@ -189,16 +189,12 @@ impl Ctx {
 | 
				
			|||||||
                                block_stack.push(self.source_ast_id_map.ast_id(&block));
 | 
					                                block_stack.push(self.source_ast_id_map.ast_id(&block));
 | 
				
			||||||
                            },
 | 
					                            },
 | 
				
			||||||
                            ast::Item(item) => {
 | 
					                            ast::Item(item) => {
 | 
				
			||||||
                                // FIXME: This triggers for macro calls in expression/pattern
 | 
					                                // FIXME: This triggers for macro calls in expression/pattern/type position
 | 
				
			||||||
                                if let Some(SyntaxKind::MACRO_TYPE) = node.parent().map(|p| p.kind()) {
 | 
					                                let mod_items = self.lower_mod_item(&item, true);
 | 
				
			||||||
                                    // Ignore macros at type position
 | 
					                                let current_block = block_stack.last();
 | 
				
			||||||
                                } else {
 | 
					                                if let (Some(mod_items), Some(block)) = (mod_items, current_block) {
 | 
				
			||||||
                                    let mod_items = self.lower_mod_item(&item, true);
 | 
					                                    if !mod_items.0.is_empty() {
 | 
				
			||||||
                                    let current_block = block_stack.last();
 | 
					                                        self.data().inner_items.entry(*block).or_default().extend(mod_items.0.iter().copied());
 | 
				
			||||||
                                    if let (Some(mod_items), Some(block)) = (mod_items, current_block) {
 | 
					 | 
				
			||||||
                                        if !mod_items.0.is_empty() {
 | 
					 | 
				
			||||||
                                            self.data().inner_items.entry(*block).or_default().extend(mod_items.0.iter().copied());
 | 
					 | 
				
			||||||
                                        }
 | 
					 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                            },
 | 
					                            },
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user