Skip to content

Commit 2fadc45

Browse files
Represent ownership transfer in RustdocVisitor::visit
Previously visit could be called multiple times, but this is inaccurate, as it deconstructs Visitor state.
1 parent 2d18504 commit 2fadc45

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/librustdoc/clean/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ use parking_lot::ReentrantMutex;
4949

5050
use crate::core::{self, DocContext};
5151
use crate::doctree;
52-
use crate::visit_ast;
5352
use crate::html::render::{cache, ExternalLocation};
5453
use crate::html::item_type::ItemType;
5554

@@ -138,7 +137,10 @@ pub struct Crate {
138137
pub masked_crates: FxHashSet<CrateNum>,
139138
}
140139

141-
impl<'a, 'tcx> Clean<Crate> for (visit_ast::RustdocVisitor<'a, 'tcx>, doctree::Module<'tcx>) {
140+
// The `()` here is rather ugly and would be great to remove. Unfortunately, we
141+
// already have a different Clean impl for `doctree::Module` which makes this
142+
// the only way to easily disambiguate.
143+
impl<'tcx> Clean<Crate> for ((), doctree::Module<'tcx>) {
142144
fn clean(&self, cx: &DocContext<'_>) -> Crate {
143145
use crate::visit_lib::LibEmbargoVisitor;
144146

src/librustdoc/core.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
392392
debug!("crate: {:?}", tcx.hir().krate());
393393

394394
let mut krate = {
395-
let mut v = RustdocVisitor::new(&ctxt);
395+
let v = RustdocVisitor::new(&ctxt);
396396
let module = v.visit(tcx.hir().krate());
397-
(v, module).clean(&ctxt)
397+
((), module).clean(&ctxt)
398398
};
399399

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

src/librustdoc/visit_ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
6868
.and_then(|def_id| self.cx.tcx.lookup_deprecation(def_id))
6969
}
7070

71-
pub fn visit(&mut self, krate: &'tcx hir::Crate) -> Module<'tcx> {
71+
pub fn visit(mut self, krate: &'tcx hir::Crate) -> Module<'tcx> {
7272
let mut module = self.visit_mod_contents(krate.span,
7373
&krate.attrs,
7474
&Spanned { span: syntax_pos::DUMMY_SP,

0 commit comments

Comments
 (0)