@@ -117,16 +117,15 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
117
117
hir:: ItemKind :: Use ( path, kind) => {
118
118
let hir:: UsePath { segments, span, .. } = * path;
119
119
let path = hir:: Path { segments, res : * res, span } ;
120
- clean_use_statement_inner ( import, name, & path, kind, cx, & mut Default :: default ( ) )
120
+ clean_use_statement_inner ( import, Some ( name) , & path, kind, cx, & mut Default :: default ( ) )
121
121
}
122
122
_ => unreachable ! ( ) ,
123
123
}
124
124
} ) ) ;
125
125
items. extend ( doc. items . values ( ) . flat_map ( |( item, renamed, _) | {
126
126
// Now we actually lower the imports, skipping everything else.
127
127
if let hir:: ItemKind :: Use ( path, hir:: UseKind :: Glob ) = item. kind {
128
- let name = renamed. unwrap_or ( kw:: Empty ) ; // using kw::Empty is a bit of a hack
129
- clean_use_statement ( item, name, path, hir:: UseKind :: Glob , cx, & mut inserted)
128
+ clean_use_statement ( item, * renamed, path, hir:: UseKind :: Glob , cx, & mut inserted)
130
129
} else {
131
130
// skip everything else
132
131
Vec :: new ( )
@@ -2792,10 +2791,11 @@ fn clean_maybe_renamed_item<'tcx>(
2792
2791
use hir:: ItemKind ;
2793
2792
2794
2793
let def_id = item. owner_id . to_def_id ( ) ;
2795
- let mut name = renamed. unwrap_or_else ( || {
2796
- // FIXME: using kw::Empty is a bit of a hack
2797
- cx. tcx . hir_opt_name ( item. hir_id ( ) ) . unwrap_or ( kw:: Empty )
2798
- } ) ;
2794
+ let mut name = if renamed. is_some ( ) {
2795
+ renamed
2796
+ } else {
2797
+ cx. tcx . hir_opt_name ( item. hir_id ( ) )
2798
+ } ;
2799
2799
2800
2800
cx. with_param_env ( def_id, |cx| {
2801
2801
let kind = match item. kind {
@@ -2836,7 +2836,7 @@ fn clean_maybe_renamed_item<'tcx>(
2836
2836
item_type : Some ( type_) ,
2837
2837
} ) ) ,
2838
2838
item. owner_id . def_id . to_def_id ( ) ,
2839
- name,
2839
+ name. unwrap ( ) ,
2840
2840
import_id,
2841
2841
renamed,
2842
2842
) ) ;
@@ -2861,13 +2861,15 @@ fn clean_maybe_renamed_item<'tcx>(
2861
2861
} ) ,
2862
2862
ItemKind :: Impl ( impl_) => return clean_impl ( impl_, item. owner_id . def_id , cx) ,
2863
2863
ItemKind :: Macro ( _, macro_def, MacroKind :: Bang ) => MacroItem ( Macro {
2864
- source : display_macro_source ( cx, name, macro_def) ,
2864
+ source : display_macro_source ( cx, name. unwrap ( ) , macro_def) ,
2865
2865
macro_rules : macro_def. macro_rules ,
2866
2866
} ) ,
2867
- ItemKind :: Macro ( _, _, macro_kind) => clean_proc_macro ( item, & mut name, macro_kind, cx) ,
2867
+ ItemKind :: Macro ( _, _, macro_kind) => {
2868
+ clean_proc_macro ( item, name. as_mut ( ) . unwrap ( ) , macro_kind, cx)
2869
+ }
2868
2870
// proc macros can have a name set by attributes
2869
2871
ItemKind :: Fn { ref sig, generics, body : body_id, .. } => {
2870
- clean_fn_or_proc_macro ( item, sig, generics, body_id, & mut name, cx)
2872
+ clean_fn_or_proc_macro ( item, sig, generics, body_id, name. as_mut ( ) . unwrap ( ) , cx)
2871
2873
}
2872
2874
ItemKind :: Trait ( _, _, _, generics, bounds, item_ids) => {
2873
2875
let items = item_ids
@@ -2883,7 +2885,7 @@ fn clean_maybe_renamed_item<'tcx>(
2883
2885
} ) )
2884
2886
}
2885
2887
ItemKind :: ExternCrate ( orig_name, _) => {
2886
- return clean_extern_crate ( item, name, orig_name, cx) ;
2888
+ return clean_extern_crate ( item, name. unwrap ( ) , orig_name, cx) ;
2887
2889
}
2888
2890
ItemKind :: Use ( path, kind) => {
2889
2891
return clean_use_statement ( item, name, path, kind, cx, & mut FxHashSet :: default ( ) ) ;
@@ -2895,7 +2897,7 @@ fn clean_maybe_renamed_item<'tcx>(
2895
2897
cx,
2896
2898
kind,
2897
2899
item. owner_id. def_id. to_def_id( ) ,
2898
- name,
2900
+ name. unwrap ( ) ,
2899
2901
import_id,
2900
2902
renamed,
2901
2903
) ]
@@ -3006,7 +3008,7 @@ fn clean_extern_crate<'tcx>(
3006
3008
3007
3009
fn clean_use_statement < ' tcx > (
3008
3010
import : & hir:: Item < ' tcx > ,
3009
- name : Symbol ,
3011
+ name : Option < Symbol > ,
3010
3012
path : & hir:: UsePath < ' tcx > ,
3011
3013
kind : hir:: UseKind ,
3012
3014
cx : & mut DocContext < ' tcx > ,
@@ -3023,7 +3025,7 @@ fn clean_use_statement<'tcx>(
3023
3025
3024
3026
fn clean_use_statement_inner < ' tcx > (
3025
3027
import : & hir:: Item < ' tcx > ,
3026
- name : Symbol ,
3028
+ name : Option < Symbol > ,
3027
3029
path : & hir:: Path < ' tcx > ,
3028
3030
kind : hir:: UseKind ,
3029
3031
cx : & mut DocContext < ' tcx > ,
@@ -3042,7 +3044,7 @@ fn clean_use_statement_inner<'tcx>(
3042
3044
let visibility = cx. tcx . visibility ( import. owner_id ) ;
3043
3045
let attrs = cx. tcx . hir_attrs ( import. hir_id ( ) ) ;
3044
3046
let inline_attr = hir_attr_lists ( attrs, sym:: doc) . get_word_attr ( sym:: inline) ;
3045
- let pub_underscore = visibility. is_public ( ) && name == kw:: Underscore ;
3047
+ let pub_underscore = visibility. is_public ( ) && name == Some ( kw:: Underscore ) ;
3046
3048
let current_mod = cx. tcx . parent_module_from_def_id ( import. owner_id . def_id ) ;
3047
3049
let import_def_id = import. owner_id . def_id ;
3048
3050
@@ -3108,6 +3110,7 @@ fn clean_use_statement_inner<'tcx>(
3108
3110
}
3109
3111
Import :: new_glob ( resolve_use_source ( cx, path) , true )
3110
3112
} else {
3113
+ let name = name. unwrap ( ) ;
3111
3114
if inline_attr. is_none ( )
3112
3115
&& let Res :: Def ( DefKind :: Mod , did) = path. res
3113
3116
&& !did. is_local ( )
0 commit comments