File tree 1 file changed +12
-3
lines changed
compiler/rustc_expand/src
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> {
1260
1260
res
1261
1261
}
1262
1262
fn declared_names ( & self ) -> Vec < Ident > {
1263
- struct ItemNameVisitor ( Vec < Ident > ) ;
1263
+ struct ItemNameVisitor ( Vec < Ident > , u8 ) ;
1264
1264
impl Visitor < ' _ > for ItemNameVisitor {
1265
1265
fn visit_item ( & mut self , i : & ast:: Item ) {
1266
+ self . 1 += 1 ;
1266
1267
if let ItemKind :: Use ( ut) = & i. kind {
1267
1268
fn collect_use_tree_leaves ( ut : & ast:: UseTree , idents : & mut Vec < Ident > ) {
1268
1269
match & ut. kind {
@@ -1280,11 +1281,19 @@ impl InvocationCollectorNode for P<ast::Item> {
1280
1281
} else {
1281
1282
self . 0 . push ( i. ident ) ;
1282
1283
}
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 ;
1284
1293
}
1285
1294
}
1286
1295
1287
- let mut v = ItemNameVisitor ( vec ! [ ] ) ;
1296
+ let mut v = ItemNameVisitor ( vec ! [ ] , 0 ) ;
1288
1297
v. visit_item ( self ) ;
1289
1298
v. 0
1290
1299
}
You can’t perform that action at this time.
0 commit comments