@@ -17,6 +17,7 @@ use rustc_data_structures::intern::Interned;
17
17
use rustc_errors:: { pluralize, struct_span_err, Applicability , MultiSpan } ;
18
18
use rustc_hir:: def:: { self , DefKind , PartialRes } ;
19
19
use rustc_middle:: metadata:: ModChild ;
20
+ use rustc_middle:: metadata:: Reexport ;
20
21
use rustc_middle:: span_bug;
21
22
use rustc_middle:: ty;
22
23
use rustc_session:: lint:: builtin:: {
@@ -27,6 +28,7 @@ use rustc_span::edit_distance::find_best_match_for_name;
27
28
use rustc_span:: hygiene:: LocalExpnId ;
28
29
use rustc_span:: symbol:: { kw, Ident , Symbol } ;
29
30
use rustc_span:: Span ;
31
+ use smallvec:: SmallVec ;
30
32
31
33
use std:: cell:: Cell ;
32
34
use std:: { mem, ptr} ;
@@ -190,6 +192,17 @@ impl<'a> Import<'a> {
190
192
ImportKind :: MacroUse | ImportKind :: MacroExport => None ,
191
193
}
192
194
}
195
+
196
+ fn simplify ( & self , r : & Resolver < ' _ , ' _ > ) -> Reexport {
197
+ let to_def_id = |id| r. local_def_id ( id) . to_def_id ( ) ;
198
+ match self . kind {
199
+ ImportKind :: Single { id, .. } => Reexport :: Single ( to_def_id ( id) ) ,
200
+ ImportKind :: Glob { id, .. } => Reexport :: Glob ( to_def_id ( id) ) ,
201
+ ImportKind :: ExternCrate { id, .. } => Reexport :: ExternCrate ( to_def_id ( id) ) ,
202
+ ImportKind :: MacroUse => Reexport :: MacroUse ,
203
+ ImportKind :: MacroExport => Reexport :: MacroExport ,
204
+ }
205
+ }
193
206
}
194
207
195
208
/// Records information about the resolution of a name in a namespace of a module.
@@ -1252,12 +1265,20 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1252
1265
1253
1266
module. for_each_child ( self , |this, ident, _, binding| {
1254
1267
if let Some ( res) = this. is_reexport ( binding) {
1268
+ let mut reexport_chain = SmallVec :: new ( ) ;
1269
+ let mut next_binding = binding;
1270
+ while let NameBindingKind :: Import { binding, import, .. } = next_binding. kind {
1271
+ reexport_chain. push ( import. simplify ( this) ) ;
1272
+ next_binding = binding;
1273
+ }
1274
+
1255
1275
reexports. push ( ModChild {
1256
1276
ident,
1257
1277
res,
1258
1278
vis : binding. vis ,
1259
1279
span : binding. span ,
1260
1280
macro_rules : false ,
1281
+ reexport_chain,
1261
1282
} ) ;
1262
1283
}
1263
1284
} ) ;
0 commit comments