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> {
1399
1399
}
1400
1400
1401
1401
fn declared_idents ( & self ) -> Vec < Ident > {
1402
- struct ItemNameVisitor ( Vec < Ident > ) ;
1402
+ struct ItemNameVisitor ( Vec < Ident > , u8 ) ;
1403
1403
impl Visitor < ' _ > for ItemNameVisitor {
1404
1404
fn visit_item ( & mut self , i : & ast:: Item ) {
1405
+ self . 1 += 1 ;
1405
1406
if let ItemKind :: Use ( ut) = & i. kind {
1406
1407
fn collect_use_tree_leaves ( ut : & ast:: UseTree , idents : & mut Vec < Ident > ) {
1407
1408
match & ut. kind {
@@ -1421,11 +1422,19 @@ impl InvocationCollectorNode for P<ast::Item> {
1421
1422
self . 0 . push ( ident) ;
1422
1423
}
1423
1424
}
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 ;
1425
1434
}
1426
1435
}
1427
1436
1428
- let mut v = ItemNameVisitor ( vec ! [ ] ) ;
1437
+ let mut v = ItemNameVisitor ( vec ! [ ] , 0 ) ;
1429
1438
v. visit_item ( self ) ;
1430
1439
v. 0
1431
1440
}
You can’t perform that action at this time.
0 commit comments