@@ -32,7 +32,7 @@ pub(crate) struct Module<'hir> {
3232 pub ( crate ) def_id : LocalDefId ,
3333 pub ( crate ) renamed : Option < Symbol > ,
3434 pub ( crate ) import_id : Option < LocalDefId > ,
35- /// The key is the item `ItemId` and the value is: (item, renamed, Vec<import_id>) .
35+ /// The key is the item `ItemId`.
3636 /// We use `FxIndexMap` to keep the insert order.
3737 ///
3838 /// `import_id` needs to be a `Vec` because we live in a dark world where you can have code
@@ -52,10 +52,7 @@ pub(crate) struct Module<'hir> {
5252 /// So in this case, we don't want to have two items but just one with attributes from all
5353 /// non-glob imports to be merged. Glob imports attributes are always ignored, whether they're
5454 /// shadowed or not.
55- pub ( crate ) items : FxIndexMap <
56- ( LocalDefId , Option < Symbol > ) ,
57- ( & ' hir hir:: Item < ' hir > , Option < Symbol > , Vec < LocalDefId > ) ,
58- > ,
55+ pub ( crate ) items : FxIndexMap < ( LocalDefId , Option < Symbol > ) , ItemEntry < ' hir > > ,
5956
6057 /// (def_id, renamed) -> (res, local_import_id)
6158 ///
@@ -70,6 +67,13 @@ pub(crate) struct Module<'hir> {
7067 pub ( crate ) foreigns : Vec < ( & ' hir hir:: ForeignItem < ' hir > , Option < Symbol > , Option < LocalDefId > ) > ,
7168}
7269
70+ #[ derive( Debug ) ]
71+ pub ( crate ) struct ItemEntry < ' hir > {
72+ pub ( crate ) item : & ' hir hir:: Item < ' hir > ,
73+ pub ( crate ) renamed : Option < Symbol > ,
74+ pub ( crate ) import_ids : Vec < LocalDefId > ,
75+ }
76+
7377impl Module < ' _ > {
7478 pub ( crate ) fn new (
7579 name : Symbol ,
@@ -172,9 +176,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
172176 {
173177 let item = self . cx . tcx . hir_expect_item ( local_def_id) ;
174178 let ( ident, _, _) = item. expect_macro ( ) ;
175- top_level_module
176- . items
177- . insert ( ( local_def_id, Some ( ident. name ) ) , ( item, None , Vec :: new ( ) ) ) ;
179+ top_level_module. items . insert (
180+ ( local_def_id, Some ( ident. name ) ) ,
181+ ItemEntry { item, renamed : None , import_ids : Vec :: new ( ) } ,
182+ ) ;
178183 }
179184 }
180185
@@ -413,10 +418,14 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
413418 . unwrap ( )
414419 . items
415420 . entry ( key)
416- . and_modify ( |v| v. 2 . push ( import_id) )
417- . or_insert_with ( || ( item, renamed, vec ! [ import_id] ) ) ;
421+ . and_modify ( |v| v. import_ids . push ( import_id) )
422+ . or_insert_with ( || ItemEntry { item, renamed, import_ids : vec ! [ import_id] } ) ;
418423 } else {
419- self . modules . last_mut ( ) . unwrap ( ) . items . insert ( key, ( item, renamed, Vec :: new ( ) ) ) ;
424+ self . modules
425+ . last_mut ( )
426+ . unwrap ( )
427+ . items
428+ . insert ( key, ItemEntry { item, renamed, import_ids : Vec :: new ( ) } ) ;
420429 }
421430 }
422431 }
0 commit comments