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 @@ -1399,9 +1399,10 @@ impl InvocationCollectorNode for P<ast::Item> {
13991399 }
14001400
14011401 fn declared_idents ( & self ) -> Vec < Ident > {
1402- struct ItemNameVisitor ( Vec < Ident > ) ;
1402+ struct ItemNameVisitor ( Vec < Ident > , u8 ) ;
14031403 impl Visitor < ' _ > for ItemNameVisitor {
14041404 fn visit_item ( & mut self , i : & ast:: Item ) {
1405+ self . 1 += 1 ;
14051406 if let ItemKind :: Use ( ut) = & i. kind {
14061407 fn collect_use_tree_leaves ( ut : & ast:: UseTree , idents : & mut Vec < Ident > ) {
14071408 match & ut. kind {
@@ -1421,11 +1422,19 @@ impl InvocationCollectorNode for P<ast::Item> {
14211422 self . 0 . push ( ident) ;
14221423 }
14231424 }
1424- visit:: walk_item ( self , i) ;
1425+ if self . 1 < 4 {
1426+ // We only visit up to 3 levels of nesting from this item, like if we were
1427+ // looking at `mod a`, we'd find item `a::b::c`. We have this limit to guard
1428+ // against deeply nested modules behind `cfg` flags, where we could spend
1429+ // significant time collecting this information purely for a potential
1430+ // diagnostic improvement.
1431+ visit:: walk_item ( self , i) ;
1432+ }
1433+ self . 1 -= 1 ;
14251434 }
14261435 }
14271436
1428- let mut v = ItemNameVisitor ( vec ! [ ] ) ;
1437+ let mut v = ItemNameVisitor ( vec ! [ ] , 0 ) ;
14291438 v. visit_item ( self ) ;
14301439 v. 0
14311440 }
You can’t perform that action at this time.
0 commit comments