Skip to content

Commit 3710002

Browse files
Make fields of RustdocVisitor private
1 parent d19a359 commit 3710002

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub struct Crate {
138138
pub masked_crates: FxHashSet<CrateNum>,
139139
}
140140

141-
impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
141+
impl<'a, 'tcx> Clean<Crate> for (visit_ast::RustdocVisitor<'a, 'tcx>, doctree::Module<'tcx>) {
142142
fn clean(&self, cx: &DocContext<'_>) -> Crate {
143143
use crate::visit_lib::LibEmbargoVisitor;
144144

@@ -159,7 +159,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
159159

160160
// Clean the crate, translating the entire libsyntax AST to one that is
161161
// understood by rustdoc.
162-
let mut module = self.module.as_ref().unwrap().clean(cx);
162+
let mut module = self.1.clean(cx);
163163
let mut masked_crates = FxHashSet::default();
164164

165165
match module.inner {
@@ -169,7 +169,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
169169
// `#[doc(masked)]` to the injected `extern crate` because it's unstable.
170170
if it.is_extern_crate()
171171
&& (it.attrs.has_doc_flag(sym::masked)
172-
|| self.cx.tcx.is_compiler_builtins(it.def_id.krate))
172+
|| cx.tcx.is_compiler_builtins(it.def_id.krate))
173173
{
174174
masked_crates.insert(it.def_id.krate);
175175
}

src/librustdoc/core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
395395

396396
let mut krate = {
397397
let mut v = RustdocVisitor::new(&ctxt);
398-
v.visit(tcx.hir().krate());
399-
v.clean(&ctxt)
398+
let module = v.visit(tcx.hir().krate());
399+
(v, module).clean(&ctxt)
400400
};
401401

402402
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {

src/librustdoc/visit_ast.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,11 @@ use crate::clean::{self, AttributesExt, NestedAttributesExt, def_id_to_path};
2020
use crate::doctree::*;
2121

2222

23-
// Looks to me like the first two of these are actually
24-
// output parameters, maybe only mutated once; perhaps
25-
// better simply to have the visit method return a tuple
26-
// containing them?
27-
2823
// Also, is there some reason that this doesn't use the 'visit'
2924
// framework from syntax?.
3025

3126
pub struct RustdocVisitor<'a, 'tcx> {
32-
pub module: Option<Module<'tcx>>,
33-
pub cx: &'a core::DocContext<'tcx>,
27+
cx: &'a core::DocContext<'tcx>,
3428
view_item_stack: FxHashSet<hir::HirId>,
3529
inlining: bool,
3630
/// Are the current module and all of its parents public?
@@ -46,7 +40,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
4640
let mut stack = FxHashSet::default();
4741
stack.insert(hir::CRATE_HIR_ID);
4842
RustdocVisitor {
49-
module: None,
5043
cx,
5144
view_item_stack: stack,
5245
inlining: false,
@@ -75,7 +68,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
7568
.and_then(|def_id| self.cx.tcx.lookup_deprecation(def_id))
7669
}
7770

78-
pub fn visit(&mut self, krate: &'tcx hir::Crate) {
71+
pub fn visit(&mut self, krate: &'tcx hir::Crate) -> Module<'tcx> {
7972
let mut module = self.visit_mod_contents(krate.span,
8073
&krate.attrs,
8174
&Spanned { span: syntax_pos::DUMMY_SP,
@@ -88,9 +81,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
8881
krate.exported_macros.iter().map(|def| self.visit_local_macro(def, None)),
8982
);
9083
module.is_crate = true;
91-
self.module = Some(module);
9284

9385
self.cx.renderinfo.borrow_mut().exact_paths = self.exact_paths.take().unwrap();
86+
87+
module
9488
}
9589

9690
pub fn visit_variant_data(&mut self, item: &'tcx hir::Item,

0 commit comments

Comments
 (0)