Skip to content

Commit 6dc4f7a

Browse files
committed
Don't unnecessarily override attrs for Module
They were never changed from the default, which you can get with `tcx.get_attrs()`.
1 parent 3ffea60 commit 6dc4f7a

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

src/librustdoc/clean/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,6 @@ impl Clean<ExternalCrate> for CrateNum {
218218

219219
impl Clean<Item> for doctree::Module<'_> {
220220
fn clean(&self, cx: &DocContext<'_>) -> Item {
221-
// maintain a stack of mod ids, for doc comment path resolution
222-
// but we also need to resolve the module's own docs based on whether its docs were written
223-
// inside or outside the module, so check for that
224-
let attrs = self.attrs.clean(cx);
225-
226221
let mut items: Vec<Item> = vec![];
227222
items.extend(self.imports.iter().flat_map(|x| x.clean(cx)));
228223
items.extend(self.foreigns.iter().map(|x| x.clean(cx)));
@@ -251,7 +246,7 @@ impl Clean<Item> for doctree::Module<'_> {
251246
ModuleItem(Module { is_crate: self.is_crate, items }),
252247
cx,
253248
);
254-
Item { attrs, source: span.clean(cx), ..what_rustc_thinks }
249+
Item { source: span.clean(cx), ..what_rustc_thinks }
255250
}
256251
}
257252

src/librustdoc/doctree.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_hir as hir;
99

1010
crate struct Module<'hir> {
1111
crate name: Option<Symbol>,
12-
crate attrs: &'hir [ast::Attribute],
1312
crate where_outer: Span,
1413
crate where_inner: Span,
1514
crate imports: Vec<Import<'hir>>,
@@ -23,13 +22,12 @@ crate struct Module<'hir> {
2322
}
2423

2524
impl Module<'hir> {
26-
crate fn new(name: Option<Symbol>, attrs: &'hir [ast::Attribute]) -> Module<'hir> {
25+
crate fn new(name: Option<Symbol>) -> Module<'hir> {
2726
Module {
2827
name,
2928
id: hir::CRATE_HIR_ID,
3029
where_outer: rustc_span::DUMMY_SP,
3130
where_inner: rustc_span::DUMMY_SP,
32-
attrs,
3331
imports: Vec::new(),
3432
mods: Vec::new(),
3533
items: Vec::new(),

src/librustdoc/visit_ast.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! The Rust AST Visitor. Extracts useful information and massages it into a form
22
//! usable for `clean`.
33
4-
use rustc_ast as ast;
54
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
65
use rustc_hir as hir;
76
use rustc_hir::def::{DefKind, Res};
@@ -64,7 +63,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
6463
crate fn visit(mut self, krate: &'tcx hir::Crate<'_>) -> Module<'tcx> {
6564
let mut module = self.visit_mod_contents(
6665
krate.item.span,
67-
krate.item.attrs,
6866
&Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Public },
6967
hir::CRATE_HIR_ID,
7068
&krate.item.module,
@@ -82,13 +80,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
8280
fn visit_mod_contents(
8381
&mut self,
8482
span: Span,
85-
attrs: &'tcx [ast::Attribute],
8683
vis: &'tcx hir::Visibility<'_>,
8784
id: hir::HirId,
8885
m: &'tcx hir::Mod<'tcx>,
8986
name: Option<Symbol>,
9087
) -> Module<'tcx> {
91-
let mut om = Module::new(name, attrs);
88+
let mut om = Module::new(name);
9289
om.where_outer = span;
9390
om.where_inner = m.inner;
9491
om.id = id;
@@ -292,7 +289,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
292289
hir::ItemKind::Mod(ref m) => {
293290
om.mods.push(self.visit_mod_contents(
294291
item.span,
295-
&item.attrs,
296292
&item.vis,
297293
item.hir_id,
298294
m,

0 commit comments

Comments
 (0)