This repository was archived by the owner on May 28, 2025. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed 
compiler/rustc_expand/src Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -1260,9 +1260,10 @@ impl InvocationCollectorNode for P<ast::Item> {
12601260        res
12611261    } 
12621262    fn  declared_names ( & self )  -> Vec < Ident >  { 
1263-         struct  ItemNameVisitor ( Vec < Ident > ) ; 
1263+         struct  ItemNameVisitor ( Vec < Ident > ,   u8 ) ; 
12641264        impl  Visitor < ' _ >  for  ItemNameVisitor  { 
12651265            fn  visit_item ( & mut  self ,  i :  & ast:: Item )  { 
1266+                 self . 1  += 1 ; 
12661267                if  let  ItemKind :: Use ( ut)  = & i. kind  { 
12671268                    fn  collect_use_tree_leaves ( ut :  & ast:: UseTree ,  idents :  & mut  Vec < Ident > )  { 
12681269                        match  & ut. kind  { 
@@ -1280,11 +1281,19 @@ impl InvocationCollectorNode for P<ast::Item> {
12801281                }  else  { 
12811282                    self . 0 . push ( i. ident ) ; 
12821283                } 
1283-                 visit:: walk_item ( self ,  i) ; 
1284+                 if  self . 1  < 4  { 
1285+                     // We only visit up to 3 levels of nesting from this item, like if we were 
1286+                     // looking at `mod a`, we'd find item `a::b::c`. We have this limit to guard 
1287+                     // against deeply nested modules behind `cfg` flags, where we could spend 
1288+                     // significant time collecting this information purely for a potential 
1289+                     // diagnostic improvement. 
1290+                     visit:: walk_item ( self ,  i) ; 
1291+                 } 
1292+                 self . 1  -= 1 ; 
12841293            } 
12851294        } 
12861295
1287-         let  mut  v = ItemNameVisitor ( vec ! [ ] ) ; 
1296+         let  mut  v = ItemNameVisitor ( vec ! [ ] ,   0 ) ; 
12881297        v. visit_item ( self ) ; 
12891298        v. 0 
12901299    } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments