mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-21 20:17:55 +00:00
Represent ownership transfer in RustdocVisitor::visit
Previously visit could be called multiple times, but this is inaccurate, as it deconstructs Visitor state.
This commit is contained in:
parent
2d18504c27
commit
2fadc4524d
@ -49,7 +49,6 @@ use parking_lot::ReentrantMutex;
|
||||
|
||||
use crate::core::{self, DocContext};
|
||||
use crate::doctree;
|
||||
use crate::visit_ast;
|
||||
use crate::html::render::{cache, ExternalLocation};
|
||||
use crate::html::item_type::ItemType;
|
||||
|
||||
@ -138,7 +137,10 @@ pub struct Crate {
|
||||
pub masked_crates: FxHashSet<CrateNum>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Clean<Crate> for (visit_ast::RustdocVisitor<'a, 'tcx>, doctree::Module<'tcx>) {
|
||||
// The `()` here is rather ugly and would be great to remove. Unfortunately, we
|
||||
// already have a different Clean impl for `doctree::Module` which makes this
|
||||
// the only way to easily disambiguate.
|
||||
impl<'tcx> Clean<Crate> for ((), doctree::Module<'tcx>) {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Crate {
|
||||
use crate::visit_lib::LibEmbargoVisitor;
|
||||
|
||||
|
@ -392,9 +392,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||
debug!("crate: {:?}", tcx.hir().krate());
|
||||
|
||||
let mut krate = {
|
||||
let mut v = RustdocVisitor::new(&ctxt);
|
||||
let v = RustdocVisitor::new(&ctxt);
|
||||
let module = v.visit(tcx.hir().krate());
|
||||
(v, module).clean(&ctxt)
|
||||
((), module).clean(&ctxt)
|
||||
};
|
||||
|
||||
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
|
||||
|
@ -68,7 +68,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
.and_then(|def_id| self.cx.tcx.lookup_deprecation(def_id))
|
||||
}
|
||||
|
||||
pub fn visit(&mut self, krate: &'tcx hir::Crate) -> Module<'tcx> {
|
||||
pub fn visit(mut self, krate: &'tcx hir::Crate) -> Module<'tcx> {
|
||||
let mut module = self.visit_mod_contents(krate.span,
|
||||
&krate.attrs,
|
||||
&Spanned { span: syntax_pos::DUMMY_SP,
|
||||
|
Loading…
Reference in New Issue
Block a user