@@ -307,8 +307,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
307
307
} )
308
308
}
309
309
310
- // Add an import directive to the current module.
311
- fn add_import_directive (
310
+ // Add an import to the current module.
311
+ fn add_import (
312
312
& mut self ,
313
313
module_path : Vec < Segment > ,
314
314
kind : ImportKind < ' a > ,
@@ -320,7 +320,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
320
320
vis : ty:: Visibility ,
321
321
) {
322
322
let current_module = self . parent_scope . module ;
323
- let directive = self . r . arenas . alloc_import_directive ( Import {
323
+ let import = self . r . arenas . alloc_import ( Import {
324
324
kind,
325
325
parent_scope : self . parent_scope ,
326
326
module_path,
@@ -336,25 +336,25 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
336
336
used : Cell :: new ( false ) ,
337
337
} ) ;
338
338
339
- debug ! ( "add_import_directive ({:?})" , directive ) ;
339
+ debug ! ( "add_import ({:?})" , import ) ;
340
340
341
- self . r . indeterminate_imports . push ( directive ) ;
342
- match directive . kind {
341
+ self . r . indeterminate_imports . push ( import ) ;
342
+ match import . kind {
343
343
// Don't add unresolved underscore imports to modules
344
344
ImportKind :: Single { target : Ident { name : kw:: Underscore , .. } , .. } => { }
345
345
ImportKind :: Single { target, type_ns_only, .. } => {
346
346
self . r . per_ns ( |this, ns| {
347
347
if !type_ns_only || ns == TypeNS {
348
348
let key = this. new_key ( target, ns) ;
349
349
let mut resolution = this. resolution ( current_module, key) . borrow_mut ( ) ;
350
- resolution. add_single_import ( directive ) ;
350
+ resolution. add_single_import ( import ) ;
351
351
}
352
352
} ) ;
353
353
}
354
354
// We don't add prelude imports to the globs since they only affect lexical scopes,
355
355
// which are not relevant to import resolution.
356
356
ImportKind :: Glob { is_prelude : true , .. } => { }
357
- ImportKind :: Glob { .. } => current_module. globs . borrow_mut ( ) . push ( directive ) ,
357
+ ImportKind :: Glob { .. } => current_module. globs . borrow_mut ( ) . push ( import ) ,
358
358
_ => unreachable ! ( ) ,
359
359
}
360
360
}
@@ -495,7 +495,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
495
495
type_ns_only,
496
496
nested,
497
497
} ;
498
- self . add_import_directive (
498
+ self . add_import (
499
499
module_path,
500
500
kind,
501
501
use_tree. span ,
@@ -511,16 +511,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
511
511
is_prelude : attr:: contains_name ( & item. attrs , sym:: prelude_import) ,
512
512
max_vis : Cell :: new ( ty:: Visibility :: Invisible ) ,
513
513
} ;
514
- self . add_import_directive (
515
- prefix,
516
- kind,
517
- use_tree. span ,
518
- id,
519
- item,
520
- root_span,
521
- item. id ,
522
- vis,
523
- ) ;
514
+ self . add_import ( prefix, kind, use_tree. span , id, item, root_span, item. id , vis) ;
524
515
}
525
516
ast:: UseTreeKind :: Nested ( ref items) => {
526
517
// Ensure there is at most one `self` in the list
@@ -636,7 +627,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
636
627
let used = self . process_legacy_macro_imports ( item, module) ;
637
628
let binding =
638
629
( module, ty:: Visibility :: Public , sp, expansion) . to_name_binding ( self . r . arenas ) ;
639
- let directive = self . r . arenas . alloc_import_directive ( Import {
630
+ let import = self . r . arenas . alloc_import ( Import {
640
631
kind : ImportKind :: ExternCrate { source : orig_name, target : ident } ,
641
632
root_id : item. id ,
642
633
id : item. id ,
@@ -651,8 +642,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
651
642
vis : Cell :: new ( vis) ,
652
643
used : Cell :: new ( used) ,
653
644
} ) ;
654
- self . r . potentially_unused_imports . push ( directive ) ;
655
- let imported_binding = self . r . import ( binding, directive ) ;
645
+ self . r . potentially_unused_imports . push ( import ) ;
646
+ let imported_binding = self . r . import ( binding, import ) ;
656
647
if ptr:: eq ( parent, self . r . graph_root ) {
657
648
if let Some ( entry) = self . r . extern_prelude . get ( & ident. modern ( ) ) {
658
649
if expansion != ExpnId :: root ( )
@@ -988,8 +979,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
988
979
}
989
980
}
990
981
991
- let macro_use_directive = |this : & Self , span| {
992
- this. r . arenas . alloc_import_directive ( Import {
982
+ let macro_use_import = |this : & Self , span| {
983
+ this. r . arenas . alloc_import ( Import {
993
984
kind : ImportKind :: MacroUse ,
994
985
root_id : item. id ,
995
986
id : item. id ,
@@ -1008,11 +999,11 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1008
999
1009
1000
let allow_shadowing = self . parent_scope . expansion == ExpnId :: root ( ) ;
1010
1001
if let Some ( span) = import_all {
1011
- let directive = macro_use_directive ( self , span) ;
1012
- self . r . potentially_unused_imports . push ( directive ) ;
1002
+ let import = macro_use_import ( self , span) ;
1003
+ self . r . potentially_unused_imports . push ( import ) ;
1013
1004
module. for_each_child ( self , |this, ident, ns, binding| {
1014
1005
if ns == MacroNS {
1015
- let imported_binding = this. r . import ( binding, directive ) ;
1006
+ let imported_binding = this. r . import ( binding, import ) ;
1016
1007
this. legacy_import_macro ( ident. name , imported_binding, span, allow_shadowing) ;
1017
1008
}
1018
1009
} ) ;
@@ -1027,9 +1018,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1027
1018
ident. span ,
1028
1019
) ;
1029
1020
if let Ok ( binding) = result {
1030
- let directive = macro_use_directive ( self , ident. span ) ;
1031
- self . r . potentially_unused_imports . push ( directive ) ;
1032
- let imported_binding = self . r . import ( binding, directive ) ;
1021
+ let import = macro_use_import ( self , ident. span ) ;
1022
+ self . r . potentially_unused_imports . push ( import ) ;
1023
+ let imported_binding = self . r . import ( binding, import ) ;
1033
1024
self . legacy_import_macro (
1034
1025
ident. name ,
1035
1026
imported_binding,
0 commit comments