@@ -191,15 +191,28 @@ pub(crate) fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> &'hir [ast:
191
191
cx. tcx . get_attrs_unchecked ( did)
192
192
}
193
193
194
+ pub ( crate ) fn item_relative_path ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> Vec < Symbol > {
195
+ tcx. def_path ( def_id)
196
+ . data
197
+ . into_iter ( )
198
+ . filter_map ( |elem| {
199
+ // extern blocks (and a few others things) have an empty name.
200
+ match elem. data . get_opt_name ( ) {
201
+ Some ( s) if !s. is_empty ( ) => Some ( s) ,
202
+ _ => None ,
203
+ }
204
+ } )
205
+ . collect ( )
206
+ }
207
+
194
208
/// Record an external fully qualified name in the external_paths cache.
195
209
///
196
210
/// These names are used later on by HTML rendering to generate things like
197
211
/// source links back to the original item.
198
212
pub ( crate ) fn record_extern_fqn ( cx : & mut DocContext < ' _ > , did : DefId , kind : ItemType ) {
199
213
let crate_name = cx. tcx . crate_name ( did. krate ) ;
200
214
201
- let relative =
202
- cx. tcx . def_path ( did) . data . into_iter ( ) . filter_map ( |elem| elem. data . get_opt_name ( ) ) ;
215
+ let relative = item_relative_path ( cx. tcx , did) ;
203
216
let fqn = if let ItemType :: Macro = kind {
204
217
// Check to see if it is a macro 2.0 or built-in macro
205
218
if matches ! (
@@ -210,7 +223,7 @@ pub(crate) fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemT
210
223
) {
211
224
once ( crate_name) . chain ( relative) . collect ( )
212
225
} else {
213
- vec ! [ crate_name, relative. last( ) . expect( "relative was empty" ) ]
226
+ vec ! [ crate_name, * relative. last( ) . expect( "relative was empty" ) ]
214
227
}
215
228
} else {
216
229
once ( crate_name) . chain ( relative) . collect ( )
0 commit comments