X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustdoc%2Fclean%2Fmod.rs;h=29eb67f023f0bde23f03e45c60c31dac4f005297;hb=a7f902b6934b23504a0716b4f2583d273fd08e2a;hp=5d81498f8d210d546ab9c747788c47f547d79445;hpb=35dbef235048f9a2939dc20effe083ca483c37ff;p=rust.git diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5d81498f8d2..ff30632daab 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -231,7 +231,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Item { let what_rustc_thinks = Item::from_hir_id_and_parts( self.id, - self.name, + Some(self.name), ModuleItem(Module { is_crate: self.is_crate, items }), cx, ); @@ -863,7 +863,8 @@ fn clean_fn_or_proc_macro( name: &mut Symbol, cx: &mut DocContext<'_>, ) -> ItemKind { - let macro_kind = item.attrs.iter().find_map(|a| { + let attrs = cx.tcx.hir().attrs(item.hir_id()); + let macro_kind = attrs.iter().find_map(|a| { if a.has_name(sym::proc_macro) { Some(MacroKind::Bang) } else if a.has_name(sym::proc_macro_derive) { @@ -877,8 +878,7 @@ fn clean_fn_or_proc_macro( match macro_kind { Some(kind) => { if kind == MacroKind::Derive { - *name = item - .attrs + *name = attrs .lists(sym::proc_macro_derive) .find_map(|mi| mi.ident()) .expect("proc-macro derives require a name") @@ -886,7 +886,7 @@ fn clean_fn_or_proc_macro( } let mut helpers = Vec::new(); - for mi in item.attrs.lists(sym::proc_macro_derive) { + for mi in attrs.lists(sym::proc_macro_derive) { if !mi.has_name(sym::attributes) { continue; } @@ -1477,7 +1477,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type { } } TyKind::Path(_) => clean_qpath(&self, cx), - TyKind::TraitObject(ref bounds, ref lifetime) => { + TyKind::TraitObject(ref bounds, ref lifetime, _) => { match bounds[0].clean(cx).trait_ { ResolvedPath { path, param_names: None, did, is_generic } => { let mut bounds: Vec = bounds[1..] @@ -1754,7 +1754,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Constant { } } -impl Clean for hir::StructField<'_> { +impl Clean for hir::FieldDef<'_> { fn clean(&self, cx: &mut DocContext<'_>) -> Item { let what_rustc_thinks = Item::from_hir_id_and_parts( self.hir_id, @@ -2102,8 +2102,9 @@ fn clean_extern_crate( let cnum = cx.tcx.extern_mod_stmt_cnum(krate.def_id).unwrap_or(LOCAL_CRATE); // this is the ID of the crate itself let crate_def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX }; + let attrs = cx.tcx.hir().attrs(krate.hir_id()); let please_inline = krate.vis.node.is_pub() - && krate.attrs.iter().any(|a| { + && attrs.iter().any(|a| { a.has_name(sym::doc) && match a.meta_item_list() { Some(l) => attr::list_contains_name(&l, sym::inline), @@ -2121,7 +2122,7 @@ fn clean_extern_crate( cx.tcx.parent_module(krate.hir_id()).to_def_id(), res, name, - Some(krate.attrs), + Some(attrs), &mut visited, ) { return items; @@ -2129,12 +2130,12 @@ fn clean_extern_crate( } // FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason vec![Item { - name: None, - attrs: box krate.attrs.clean(cx), + name: Some(name), + attrs: box attrs.clean(cx), source: krate.span.clean(cx), def_id: crate_def_id, visibility: krate.vis.clean(cx), - kind: box ExternCrateItem(name, orig_name), + kind: box ExternCrateItem { src: orig_name }, }] } @@ -2152,7 +2153,8 @@ fn clean_use_statement( return Vec::new(); } - let inline_attr = import.attrs.lists(sym::doc).get_word_attr(sym::inline); + let attrs = cx.tcx.hir().attrs(import.hir_id()); + let inline_attr = attrs.lists(sym::doc).get_word_attr(sym::inline); let pub_underscore = import.vis.node.is_pub() && name == kw::Underscore; if pub_underscore { @@ -2174,7 +2176,7 @@ fn clean_use_statement( // Don't inline doc(hidden) imports so they can be stripped at a later stage. let mut denied = !import.vis.node.is_pub() || pub_underscore - || import.attrs.iter().any(|a| { + || attrs.iter().any(|a| { a.has_name(sym::doc) && match a.meta_item_list() { Some(l) => { @@ -2214,7 +2216,7 @@ fn clean_use_statement( cx.tcx.parent_module(import.hir_id()).to_def_id(), path.res, name, - Some(import.attrs), + Some(attrs), &mut visited, ) { items.push(Item::from_def_id_and_parts(