Rollup merge of #80340 - jyn514:less-modules-attrs, r=GuillaumeGomez
Don't unnecessarily override attrs for Module They were never changed from the default, which you can get with `tcx.get_attrs()`.
This commit is contained in:
commit
28267e3839
3 changed files with 3 additions and 14 deletions
|
|
@ -218,11 +218,6 @@ impl Clean<ExternalCrate> for CrateNum {
|
|||
|
||||
impl Clean<Item> for doctree::Module<'_> {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
// maintain a stack of mod ids, for doc comment path resolution
|
||||
// but we also need to resolve the module's own docs based on whether its docs were written
|
||||
// inside or outside the module, so check for that
|
||||
let attrs = self.attrs.clean(cx);
|
||||
|
||||
let mut items: Vec<Item> = vec![];
|
||||
items.extend(self.imports.iter().flat_map(|x| x.clean(cx)));
|
||||
items.extend(self.foreigns.iter().map(|x| x.clean(cx)));
|
||||
|
|
@ -251,7 +246,7 @@ impl Clean<Item> for doctree::Module<'_> {
|
|||
ModuleItem(Module { is_crate: self.is_crate, items }),
|
||||
cx,
|
||||
);
|
||||
Item { attrs, source: span.clean(cx), ..what_rustc_thinks }
|
||||
Item { source: span.clean(cx), ..what_rustc_thinks }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ use rustc_hir as hir;
|
|||
|
||||
crate struct Module<'hir> {
|
||||
crate name: Option<Symbol>,
|
||||
crate attrs: &'hir [ast::Attribute],
|
||||
crate where_outer: Span,
|
||||
crate where_inner: Span,
|
||||
crate imports: Vec<Import<'hir>>,
|
||||
|
|
@ -23,13 +22,12 @@ crate struct Module<'hir> {
|
|||
}
|
||||
|
||||
impl Module<'hir> {
|
||||
crate fn new(name: Option<Symbol>, attrs: &'hir [ast::Attribute]) -> Module<'hir> {
|
||||
crate fn new(name: Option<Symbol>) -> Module<'hir> {
|
||||
Module {
|
||||
name,
|
||||
id: hir::CRATE_HIR_ID,
|
||||
where_outer: rustc_span::DUMMY_SP,
|
||||
where_inner: rustc_span::DUMMY_SP,
|
||||
attrs,
|
||||
imports: Vec::new(),
|
||||
mods: Vec::new(),
|
||||
items: Vec::new(),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
//! The Rust AST Visitor. Extracts useful information and massages it into a form
|
||||
//! usable for `clean`.
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
|
|
@ -64,7 +63,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
crate fn visit(mut self, krate: &'tcx hir::Crate<'_>) -> Module<'tcx> {
|
||||
let mut module = self.visit_mod_contents(
|
||||
krate.item.span,
|
||||
krate.item.attrs,
|
||||
&Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Public },
|
||||
hir::CRATE_HIR_ID,
|
||||
&krate.item.module,
|
||||
|
|
@ -82,13 +80,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
fn visit_mod_contents(
|
||||
&mut self,
|
||||
span: Span,
|
||||
attrs: &'tcx [ast::Attribute],
|
||||
vis: &'tcx hir::Visibility<'_>,
|
||||
id: hir::HirId,
|
||||
m: &'tcx hir::Mod<'tcx>,
|
||||
name: Option<Symbol>,
|
||||
) -> Module<'tcx> {
|
||||
let mut om = Module::new(name, attrs);
|
||||
let mut om = Module::new(name);
|
||||
om.where_outer = span;
|
||||
om.where_inner = m.inner;
|
||||
om.id = id;
|
||||
|
|
@ -292,7 +289,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
hir::ItemKind::Mod(ref m) => {
|
||||
om.mods.push(self.visit_mod_contents(
|
||||
item.span,
|
||||
&item.attrs,
|
||||
&item.vis,
|
||||
item.hir_id,
|
||||
m,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue