]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/clean/mod.rs
Auto merge of #79780 - camelid:use-summary_opts, r=GuillaumeGomez
[rust.git] / src / librustdoc / clean / mod.rs
index bf3b994c52a8f4bb3dfd017b78b488886cb6867b..16274430902e42486f3020117f4020e74b4c5efe 100644 (file)
@@ -1974,16 +1974,13 @@ fn clean(&self, cx: &DocContext<'_>) -> BareFunctionDecl {
     }
 }
 
-impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Ident>) {
+impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
     fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
         use hir::ItemKind;
 
         let (item, renamed) = self;
         let def_id = cx.tcx.hir().local_def_id(item.hir_id).to_def_id();
-        let mut name = match renamed {
-            Some(ident) => ident.name,
-            None => cx.tcx.hir().name(item.hir_id),
-        };
+        let mut name = renamed.unwrap_or_else(|| cx.tcx.hir().name(item.hir_id));
         cx.with_param_env(def_id, || {
             let kind = match item.kind {
                 ItemKind::Static(ty, mutability, body_id) => StaticItem(Static {
@@ -2266,7 +2263,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
             name: None,
             attrs: self.attrs.clean(cx),
             source: self.span.clean(cx),
-            def_id: DefId::local(CRATE_DEF_INDEX),
+            def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
             visibility: self.vis.clean(cx),
             stability: None,
             const_stability: None,
@@ -2276,7 +2273,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
     }
 }
 
-impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Ident>) {
+impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
     fn clean(&self, cx: &DocContext<'_>) -> Item {
         let (item, renamed) = self;
         cx.with_param_env(cx.tcx.hir().local_def_id(item.hir_id).to_def_id(), || {
@@ -2310,7 +2307,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
 
             Item::from_hir_id_and_parts(
                 item.hir_id,
-                Some(renamed.unwrap_or(item.ident).name),
+                Some(renamed.unwrap_or(item.ident.name)),
                 kind,
                 cx,
             )
@@ -2318,10 +2315,10 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
     }
 }
 
-impl Clean<Item> for (&hir::MacroDef<'_>, Option<Ident>) {
+impl Clean<Item> for (&hir::MacroDef<'_>, Option<Symbol>) {
     fn clean(&self, cx: &DocContext<'_>) -> Item {
         let (item, renamed) = self;
-        let name = renamed.unwrap_or(item.ident).name;
+        let name = renamed.unwrap_or(item.ident.name);
         let tts = item.ast.body.inner_tokens().trees().collect::<Vec<_>>();
         // Extract the spans of all matchers. They represent the "interface" of the macro.
         let matchers = tts.chunks(4).map(|arm| arm[0].span()).collect::<Vec<_>>();