Skip to content

Commit 3835d4a

Browse files
Remove useless code in propagate_doc_cfg.rs
1 parent e1d6b79 commit 3835d4a

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

src/librustdoc/passes/propagate_doc_cfg.rs

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
//! Propagates [`#[doc(cfg(...))]`](https://github.com/rust-lang/rust/issues/43781) to child items.
22
3-
use std::sync::Arc;
4-
53
use rustc_ast::token::{Token, TokenKind};
64
use rustc_ast::tokenstream::{TokenStream, TokenTree};
7-
use rustc_hir::def_id::LocalDefId;
85
use rustc_hir::{AttrArgs, Attribute};
96
use rustc_span::symbol::sym;
107

11-
use crate::clean::cfg::Cfg;
128
use crate::clean::inline::{load_attrs, merge_attrs};
139
use crate::clean::{CfgInfo, Crate, Item, ItemKind};
1410
use crate::core::DocContext;
@@ -22,13 +18,10 @@ pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass {
2218
};
2319

2420
pub(crate) fn propagate_doc_cfg(cr: Crate, cx: &mut DocContext<'_>) -> Crate {
25-
CfgPropagator { parent_cfg: None, parent: None, cx, cfg_info: CfgInfo::default() }
26-
.fold_crate(cr)
21+
CfgPropagator { cx, cfg_info: CfgInfo::default() }.fold_crate(cr)
2722
}
2823

2924
struct CfgPropagator<'a, 'tcx> {
30-
parent_cfg: Option<Arc<Cfg>>,
31-
parent: Option<LocalDefId>,
3225
cx: &'a mut DocContext<'tcx>,
3326
cfg_info: CfgInfo,
3427
}
@@ -131,21 +124,11 @@ impl CfgPropagator<'_, '_> {
131124
impl DocFolder for CfgPropagator<'_, '_> {
132125
fn fold_item(&mut self, mut item: Item) -> Option<Item> {
133126
let old_cfg_info = self.cfg_info.clone();
134-
let old_parent_cfg = self.parent_cfg.clone();
135127

136128
self.merge_with_parent_attributes(&mut item);
137-
self.parent_cfg = item.inner.cfg.clone();
138129

139-
let old_parent =
140-
if let Some(def_id) = item.item_id.as_def_id().and_then(|def_id| def_id.as_local()) {
141-
self.parent.replace(def_id)
142-
} else {
143-
self.parent.take()
144-
};
145130
let result = self.fold_item_recur(item);
146131
self.cfg_info = old_cfg_info;
147-
self.parent_cfg = old_parent_cfg;
148-
self.parent = old_parent;
149132

150133
Some(result)
151134
}

0 commit comments

Comments
 (0)