Move top-level Clean impl to function
This allows us to pass it a `&mut DocContext` which will allow removal of RefCells, etc. in the following commits. It's also somewhat a unique Clean impl in that it previously ignored `self` (re-retriveing hir::Crate), which it no longer needs to do.
This commit is contained in:
parent
a77247acb1
commit
e2b6f4c662
|
@ -136,10 +136,7 @@ pub struct Crate {
|
||||||
pub collapsed: bool,
|
pub collapsed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<Crate> for hir::Crate {
|
pub fn krate(cx: &mut DocContext<'a>) -> Crate {
|
||||||
// note that self here is ignored in favor of `cx.tcx.hir().krate()` since
|
|
||||||
// that gets around tying self's lifetime to the '_ in cx.
|
|
||||||
fn clean(&self, cx: &DocContext<'_>) -> Crate {
|
|
||||||
use crate::visit_lib::LibEmbargoVisitor;
|
use crate::visit_lib::LibEmbargoVisitor;
|
||||||
|
|
||||||
let v = crate::visit_ast::RustdocVisitor::new(&cx);
|
let v = crate::visit_ast::RustdocVisitor::new(&cx);
|
||||||
|
@ -224,7 +221,6 @@ impl Clean<Crate> for hir::Crate {
|
||||||
masked_crates,
|
masked_crates,
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
@ -30,7 +30,7 @@ use std::rc::Rc;
|
||||||
|
|
||||||
use crate::config::{Options as RustdocOptions, RenderOptions};
|
use crate::config::{Options as RustdocOptions, RenderOptions};
|
||||||
use crate::clean;
|
use crate::clean;
|
||||||
use crate::clean::{Clean, MAX_DEF_ID, AttributesExt};
|
use crate::clean::{MAX_DEF_ID, AttributesExt};
|
||||||
use crate::html::render::RenderInfo;
|
use crate::html::render::RenderInfo;
|
||||||
|
|
||||||
use crate::passes;
|
use crate::passes;
|
||||||
|
@ -363,7 +363,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||||
let mut renderinfo = RenderInfo::default();
|
let mut renderinfo = RenderInfo::default();
|
||||||
renderinfo.access_levels = access_levels;
|
renderinfo.access_levels = access_levels;
|
||||||
|
|
||||||
let ctxt = DocContext {
|
let mut ctxt = DocContext {
|
||||||
tcx,
|
tcx,
|
||||||
resolver,
|
resolver,
|
||||||
cstore: compiler.cstore().clone(),
|
cstore: compiler.cstore().clone(),
|
||||||
|
@ -383,7 +383,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||||
};
|
};
|
||||||
debug!("crate: {:?}", tcx.hir().krate());
|
debug!("crate: {:?}", tcx.hir().krate());
|
||||||
|
|
||||||
let mut krate = tcx.hir().krate().clean(&ctxt);
|
let mut krate = clean::krate(&mut ctxt);
|
||||||
|
|
||||||
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
|
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
|
||||||
let mut msg = diag.struct_warn(&format!("the `#![doc({})]` attribute is \
|
let mut msg = diag.struct_warn(&format!("the `#![doc({})]` attribute is \
|
||||||
|
|
Loading…
Reference in New Issue