rustdoc: fix fallout from the addition of a 'tcx lifetime on tcx.
This commit is contained in:
parent
f7a997be05
commit
8bfbcddf53
@ -21,7 +21,7 @@ use rustc::middle::ty;
|
||||
use rustc::middle::subst;
|
||||
use rustc::middle::stability;
|
||||
|
||||
use core;
|
||||
use core::DocContext;
|
||||
use doctree;
|
||||
use clean;
|
||||
|
||||
@ -39,12 +39,11 @@ use super::Clean;
|
||||
///
|
||||
/// The returned value is `None` if the `id` could not be inlined, and `Some`
|
||||
/// of a vector of items if it was successfully expanded.
|
||||
pub fn try_inline(id: ast::NodeId, into: Option<ast::Ident>)
|
||||
pub fn try_inline(cx: &DocContext, id: ast::NodeId, into: Option<ast::Ident>)
|
||||
-> Option<Vec<clean::Item>> {
|
||||
let cx = ::ctxtkey.get().unwrap();
|
||||
let tcx = match cx.maybe_typed {
|
||||
core::Typed(ref tycx) => tycx,
|
||||
core::NotTyped(_) => return None,
|
||||
let tcx = match cx.tcx_opt() {
|
||||
Some(tcx) => tcx,
|
||||
None => return None,
|
||||
};
|
||||
let def = match tcx.def_map.borrow().find(&id) {
|
||||
Some(def) => *def,
|
||||
@ -52,11 +51,11 @@ pub fn try_inline(id: ast::NodeId, into: Option<ast::Ident>)
|
||||
};
|
||||
let did = def.def_id();
|
||||
if ast_util::is_local(did) { return None }
|
||||
try_inline_def(&**cx, tcx, def).map(|vec| {
|
||||
try_inline_def(cx, tcx, def).map(|vec| {
|
||||
vec.move_iter().map(|mut item| {
|
||||
match into {
|
||||
Some(into) if item.name.is_some() => {
|
||||
item.name = Some(into.clean());
|
||||
item.name = Some(into.clean(cx));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@ -65,15 +64,14 @@ pub fn try_inline(id: ast::NodeId, into: Option<ast::Ident>)
|
||||
})
|
||||
}
|
||||
|
||||
fn try_inline_def(cx: &core::DocContext,
|
||||
tcx: &ty::ctxt,
|
||||
fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt,
|
||||
def: def::Def) -> Option<Vec<clean::Item>> {
|
||||
let mut ret = Vec::new();
|
||||
let did = def.def_id();
|
||||
let inner = match def {
|
||||
def::DefTrait(did) => {
|
||||
record_extern_fqn(cx, did, clean::TypeTrait);
|
||||
clean::TraitItem(build_external_trait(tcx, did))
|
||||
clean::TraitItem(build_external_trait(cx, tcx, did))
|
||||
}
|
||||
def::DefFn(did, style) => {
|
||||
// If this function is a tuple struct constructor, we just skip it
|
||||
@ -82,17 +80,17 @@ fn try_inline_def(cx: &core::DocContext,
|
||||
return None
|
||||
}
|
||||
record_extern_fqn(cx, did, clean::TypeFunction);
|
||||
clean::FunctionItem(build_external_function(tcx, did, style))
|
||||
clean::FunctionItem(build_external_function(cx, tcx, did, style))
|
||||
}
|
||||
def::DefStruct(did) => {
|
||||
record_extern_fqn(cx, did, clean::TypeStruct);
|
||||
ret.extend(build_impls(cx, tcx, did).move_iter());
|
||||
clean::StructItem(build_struct(tcx, did))
|
||||
clean::StructItem(build_struct(cx, tcx, did))
|
||||
}
|
||||
def::DefTy(did) => {
|
||||
record_extern_fqn(cx, did, clean::TypeEnum);
|
||||
ret.extend(build_impls(cx, tcx, did).move_iter());
|
||||
build_type(tcx, did)
|
||||
build_type(cx, tcx, did)
|
||||
}
|
||||
// Assume that the enum type is reexported next to the variant, and
|
||||
// variants don't show up in documentation specially.
|
||||
@ -103,7 +101,7 @@ fn try_inline_def(cx: &core::DocContext,
|
||||
}
|
||||
def::DefStatic(did, mtbl) => {
|
||||
record_extern_fqn(cx, did, clean::TypeStatic);
|
||||
clean::StaticItem(build_static(tcx, did, mtbl))
|
||||
clean::StaticItem(build_static(cx, tcx, did, mtbl))
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
@ -112,20 +110,21 @@ fn try_inline_def(cx: &core::DocContext,
|
||||
ret.push(clean::Item {
|
||||
source: clean::Span::empty(),
|
||||
name: Some(fqn.last().unwrap().to_string()),
|
||||
attrs: load_attrs(tcx, did),
|
||||
attrs: load_attrs(cx, tcx, did),
|
||||
inner: inner,
|
||||
visibility: Some(ast::Public),
|
||||
stability: stability::lookup(tcx, did).clean(),
|
||||
stability: stability::lookup(tcx, did).clean(cx),
|
||||
def_id: did,
|
||||
});
|
||||
Some(ret)
|
||||
}
|
||||
|
||||
pub fn load_attrs(tcx: &ty::ctxt, did: ast::DefId) -> Vec<clean::Attribute> {
|
||||
pub fn load_attrs(cx: &DocContext, tcx: &ty::ctxt,
|
||||
did: ast::DefId) -> Vec<clean::Attribute> {
|
||||
let mut attrs = Vec::new();
|
||||
csearch::get_item_attrs(&tcx.sess.cstore, did, |v| {
|
||||
attrs.extend(v.move_iter().map(|a| {
|
||||
a.clean()
|
||||
a.clean(cx)
|
||||
}));
|
||||
});
|
||||
attrs
|
||||
@ -135,22 +134,21 @@ pub fn load_attrs(tcx: &ty::ctxt, did: ast::DefId) -> Vec<clean::Attribute> {
|
||||
///
|
||||
/// These names are used later on by HTML rendering to generate things like
|
||||
/// source links back to the original item.
|
||||
pub fn record_extern_fqn(cx: &core::DocContext,
|
||||
did: ast::DefId,
|
||||
kind: clean::TypeKind) {
|
||||
match cx.maybe_typed {
|
||||
core::Typed(ref tcx) => {
|
||||
pub fn record_extern_fqn(cx: &DocContext, did: ast::DefId, kind: clean::TypeKind) {
|
||||
match cx.tcx_opt() {
|
||||
Some(tcx) => {
|
||||
let fqn = csearch::get_item_path(tcx, did);
|
||||
let fqn = fqn.move_iter().map(|i| i.to_string()).collect();
|
||||
cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, kind));
|
||||
}
|
||||
core::NotTyped(..) => {}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_external_trait(tcx: &ty::ctxt, did: ast::DefId) -> clean::Trait {
|
||||
pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt,
|
||||
did: ast::DefId) -> clean::Trait {
|
||||
let def = ty::lookup_trait_def(tcx, did);
|
||||
let trait_items = ty::trait_items(tcx, did).clean();
|
||||
let trait_items = ty::trait_items(tcx, did).clean(cx);
|
||||
let provided = ty::provided_trait_methods(tcx, did);
|
||||
let mut items = trait_items.move_iter().map(|trait_item| {
|
||||
if provided.iter().any(|a| a.def_id == trait_item.def_id) {
|
||||
@ -160,29 +158,29 @@ pub fn build_external_trait(tcx: &ty::ctxt, did: ast::DefId) -> clean::Trait {
|
||||
}
|
||||
});
|
||||
let trait_def = ty::lookup_trait_def(tcx, did);
|
||||
let bounds = trait_def.bounds.clean();
|
||||
let bounds = trait_def.bounds.clean(cx);
|
||||
clean::Trait {
|
||||
generics: (&def.generics, subst::TypeSpace).clean(),
|
||||
generics: (&def.generics, subst::TypeSpace).clean(cx),
|
||||
items: items.collect(),
|
||||
bounds: bounds,
|
||||
}
|
||||
}
|
||||
|
||||
fn build_external_function(tcx: &ty::ctxt,
|
||||
fn build_external_function(cx: &DocContext, tcx: &ty::ctxt,
|
||||
did: ast::DefId,
|
||||
style: ast::FnStyle) -> clean::Function {
|
||||
let t = ty::lookup_item_type(tcx, did);
|
||||
clean::Function {
|
||||
decl: match ty::get(t.ty).sty {
|
||||
ty::ty_bare_fn(ref f) => (did, &f.sig).clean(),
|
||||
ty::ty_bare_fn(ref f) => (did, &f.sig).clean(cx),
|
||||
_ => fail!("bad function"),
|
||||
},
|
||||
generics: (&t.generics, subst::FnSpace).clean(),
|
||||
generics: (&t.generics, subst::FnSpace).clean(cx),
|
||||
fn_style: style,
|
||||
}
|
||||
}
|
||||
|
||||
fn build_struct(tcx: &ty::ctxt, did: ast::DefId) -> clean::Struct {
|
||||
fn build_struct(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Struct {
|
||||
use syntax::parse::token::special_idents::unnamed_field;
|
||||
|
||||
let t = ty::lookup_item_type(tcx, did);
|
||||
@ -195,33 +193,32 @@ fn build_struct(tcx: &ty::ctxt, did: ast::DefId) -> clean::Struct {
|
||||
[ref f, ..] if f.name == unnamed_field.name => doctree::Tuple,
|
||||
_ => doctree::Plain,
|
||||
},
|
||||
generics: (&t.generics, subst::TypeSpace).clean(),
|
||||
fields: fields.clean(),
|
||||
generics: (&t.generics, subst::TypeSpace).clean(cx),
|
||||
fields: fields.clean(cx),
|
||||
fields_stripped: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn build_type(tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEnum {
|
||||
fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEnum {
|
||||
let t = ty::lookup_item_type(tcx, did);
|
||||
match ty::get(t.ty).sty {
|
||||
ty::ty_enum(edid, _) if !csearch::is_typedef(&tcx.sess.cstore, did) => {
|
||||
return clean::EnumItem(clean::Enum {
|
||||
generics: (&t.generics, subst::TypeSpace).clean(),
|
||||
generics: (&t.generics, subst::TypeSpace).clean(cx),
|
||||
variants_stripped: false,
|
||||
variants: ty::enum_variants(tcx, edid).clean(),
|
||||
variants: ty::enum_variants(tcx, edid).clean(cx),
|
||||
})
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
clean::TypedefItem(clean::Typedef {
|
||||
type_: t.ty.clean(),
|
||||
generics: (&t.generics, subst::TypeSpace).clean(),
|
||||
type_: t.ty.clean(cx),
|
||||
generics: (&t.generics, subst::TypeSpace).clean(cx),
|
||||
})
|
||||
}
|
||||
|
||||
fn build_impls(cx: &core::DocContext,
|
||||
tcx: &ty::ctxt,
|
||||
fn build_impls(cx: &DocContext, tcx: &ty::ctxt,
|
||||
did: ast::DefId) -> Vec<clean::Item> {
|
||||
ty::populate_implementations_for_type_if_necessary(tcx, did);
|
||||
let mut impls = Vec::new();
|
||||
@ -248,8 +245,7 @@ fn build_impls(cx: &core::DocContext,
|
||||
populate_impls(cx, tcx, def, &mut impls)
|
||||
});
|
||||
|
||||
fn populate_impls(cx: &core::DocContext,
|
||||
tcx: &ty::ctxt,
|
||||
fn populate_impls(cx: &DocContext, tcx: &ty::ctxt,
|
||||
def: decoder::DefLike,
|
||||
impls: &mut Vec<Option<clean::Item>>) {
|
||||
match def {
|
||||
@ -269,8 +265,7 @@ fn build_impls(cx: &core::DocContext,
|
||||
impls.move_iter().filter_map(|a| a).collect()
|
||||
}
|
||||
|
||||
fn build_impl(cx: &core::DocContext,
|
||||
tcx: &ty::ctxt,
|
||||
fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
|
||||
did: ast::DefId) -> Option<clean::Item> {
|
||||
if !cx.inlined.borrow_mut().as_mut().unwrap().insert(did) {
|
||||
return None
|
||||
@ -280,7 +275,7 @@ fn build_impl(cx: &core::DocContext,
|
||||
// If this is an impl for a #[doc(hidden)] trait, be sure to not inline it.
|
||||
match associated_trait {
|
||||
Some(ref t) => {
|
||||
let trait_attrs = load_attrs(tcx, t.def_id);
|
||||
let trait_attrs = load_attrs(cx, tcx, t.def_id);
|
||||
if trait_attrs.iter().any(|a| is_doc_hidden(a)) {
|
||||
return None
|
||||
}
|
||||
@ -288,7 +283,7 @@ fn build_impl(cx: &core::DocContext,
|
||||
None => {}
|
||||
}
|
||||
|
||||
let attrs = load_attrs(tcx, did);
|
||||
let attrs = load_attrs(cx, tcx, did);
|
||||
let ty = ty::lookup_item_type(tcx, did);
|
||||
let trait_items = csearch::get_impl_items(&tcx.sess.cstore, did)
|
||||
.iter()
|
||||
@ -300,7 +295,7 @@ fn build_impl(cx: &core::DocContext,
|
||||
if method.vis != ast::Public && associated_trait.is_none() {
|
||||
return None
|
||||
}
|
||||
let mut item = method.clean();
|
||||
let mut item = method.clean(cx);
|
||||
item.inner = match item.inner.clone() {
|
||||
clean::TyMethodItem(clean::TyMethod {
|
||||
fn_style, decl, self_, generics
|
||||
@ -321,21 +316,21 @@ fn build_impl(cx: &core::DocContext,
|
||||
return Some(clean::Item {
|
||||
inner: clean::ImplItem(clean::Impl {
|
||||
derived: clean::detect_derived(attrs.as_slice()),
|
||||
trait_: associated_trait.clean().map(|bound| {
|
||||
trait_: associated_trait.clean(cx).map(|bound| {
|
||||
match bound {
|
||||
clean::TraitBound(ty) => ty,
|
||||
clean::RegionBound => unreachable!(),
|
||||
}
|
||||
}),
|
||||
for_: ty.ty.clean(),
|
||||
generics: (&ty.generics, subst::TypeSpace).clean(),
|
||||
for_: ty.ty.clean(cx),
|
||||
generics: (&ty.generics, subst::TypeSpace).clean(cx),
|
||||
items: trait_items,
|
||||
}),
|
||||
source: clean::Span::empty(),
|
||||
name: None,
|
||||
attrs: attrs,
|
||||
visibility: Some(ast::Inherited),
|
||||
stability: stability::lookup(tcx, did).clean(),
|
||||
stability: stability::lookup(tcx, did).clean(cx),
|
||||
def_id: did,
|
||||
});
|
||||
|
||||
@ -354,7 +349,7 @@ fn build_impl(cx: &core::DocContext,
|
||||
}
|
||||
}
|
||||
|
||||
fn build_module(cx: &core::DocContext, tcx: &ty::ctxt,
|
||||
fn build_module(cx: &DocContext, tcx: &ty::ctxt,
|
||||
did: ast::DefId) -> clean::Module {
|
||||
let mut items = Vec::new();
|
||||
fill_in(cx, tcx, did, &mut items);
|
||||
@ -365,7 +360,7 @@ fn build_module(cx: &core::DocContext, tcx: &ty::ctxt,
|
||||
|
||||
// FIXME: this doesn't handle reexports inside the module itself.
|
||||
// Should they be handled?
|
||||
fn fill_in(cx: &core::DocContext, tcx: &ty::ctxt, did: ast::DefId,
|
||||
fn fill_in(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId,
|
||||
items: &mut Vec<clean::Item>) {
|
||||
csearch::each_child_of_item(&tcx.sess.cstore, did, |def, _, vis| {
|
||||
match def {
|
||||
@ -387,11 +382,11 @@ fn build_module(cx: &core::DocContext, tcx: &ty::ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
fn build_static(tcx: &ty::ctxt,
|
||||
fn build_static(cx: &DocContext, tcx: &ty::ctxt,
|
||||
did: ast::DefId,
|
||||
mutable: bool) -> clean::Static {
|
||||
clean::Static {
|
||||
type_: ty::lookup_item_type(tcx, did).ty.clean(),
|
||||
type_: ty::lookup_item_type(tcx, did).ty.clean(cx),
|
||||
mutability: if mutable {clean::Mutable} else {clean::Immutable},
|
||||
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,23 +22,24 @@ use std::cell::RefCell;
|
||||
use std::gc::GC;
|
||||
use std::os;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use arena::TypedArena;
|
||||
|
||||
use visit_ast::RustdocVisitor;
|
||||
use clean;
|
||||
use clean::Clean;
|
||||
|
||||
/// Are we generating documentation (`Typed`) or tests (`NotTyped`)?
|
||||
pub enum MaybeTyped {
|
||||
Typed(middle::ty::ctxt),
|
||||
pub enum MaybeTyped<'tcx> {
|
||||
Typed(middle::ty::ctxt<'tcx>),
|
||||
NotTyped(driver::session::Session)
|
||||
}
|
||||
|
||||
pub type ExternalPaths = RefCell<Option<HashMap<ast::DefId,
|
||||
(Vec<String>, clean::TypeKind)>>>;
|
||||
|
||||
pub struct DocContext {
|
||||
pub struct DocContext<'tcx> {
|
||||
pub krate: ast::Crate,
|
||||
pub maybe_typed: MaybeTyped,
|
||||
pub maybe_typed: MaybeTyped<'tcx>,
|
||||
pub src: Path,
|
||||
pub external_paths: ExternalPaths,
|
||||
pub external_traits: RefCell<Option<HashMap<ast::DefId, clean::Trait>>>,
|
||||
@ -47,7 +48,7 @@ pub struct DocContext {
|
||||
pub populated_crate_impls: RefCell<HashSet<ast::CrateNum>>,
|
||||
}
|
||||
|
||||
impl DocContext {
|
||||
impl<'tcx> DocContext<'tcx> {
|
||||
pub fn sess<'a>(&'a self) -> &'a driver::session::Session {
|
||||
match self.maybe_typed {
|
||||
Typed(ref tcx) => &tcx.sess,
|
||||
@ -55,14 +56,14 @@ impl DocContext {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tcx_opt<'a>(&'a self) -> Option<&'a ty::ctxt> {
|
||||
pub fn tcx_opt<'a>(&'a self) -> Option<&'a ty::ctxt<'tcx>> {
|
||||
match self.maybe_typed {
|
||||
Typed(ref tcx) => Some(tcx),
|
||||
NotTyped(_) => None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tcx<'a>(&'a self) -> &'a ty::ctxt {
|
||||
pub fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
|
||||
let tcx_opt = self.tcx_opt();
|
||||
tcx_opt.expect("tcx not present")
|
||||
}
|
||||
@ -80,9 +81,10 @@ pub struct CrateAnalysis {
|
||||
pub type Externs = HashMap<String, Vec<String>>;
|
||||
|
||||
/// Parses, resolves, and typechecks the given crate
|
||||
fn get_ast_and_resolve(cpath: &Path, libs: Vec<Path>, cfgs: Vec<String>,
|
||||
externs: Externs, triple: Option<String>)
|
||||
-> (DocContext, CrateAnalysis) {
|
||||
fn get_ast_and_resolve<'tcx>(cpath: &Path, libs: Vec<Path>, cfgs: Vec<String>,
|
||||
externs: Externs, triple: Option<String>,
|
||||
type_arena: &'tcx TypedArena<ty::t_box_>)
|
||||
-> (DocContext<'tcx>, CrateAnalysis) {
|
||||
use syntax::codemap::dummy_spanned;
|
||||
use rustc::driver::driver::{FileInput,
|
||||
phase_1_parse_input,
|
||||
@ -131,7 +133,7 @@ fn get_ast_and_resolve(cpath: &Path, libs: Vec<Path>, cfgs: Vec<String>,
|
||||
|
||||
let driver::driver::CrateAnalysis {
|
||||
exported_items, public_items, ty_cx, ..
|
||||
} = phase_3_run_analysis_passes(sess, &krate, ast_map, name);
|
||||
} = phase_3_run_analysis_passes(sess, &krate, ast_map, type_arena, name);
|
||||
|
||||
debug!("crate: {:?}", krate);
|
||||
(DocContext {
|
||||
@ -156,14 +158,14 @@ fn get_ast_and_resolve(cpath: &Path, libs: Vec<Path>, cfgs: Vec<String>,
|
||||
pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs,
|
||||
path: &Path, triple: Option<String>)
|
||||
-> (clean::Crate, CrateAnalysis) {
|
||||
let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs, externs, triple);
|
||||
let ctxt = box(GC) ctxt;
|
||||
super::ctxtkey.replace(Some(ctxt));
|
||||
let type_arena = TypedArena::new();
|
||||
let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs, externs,
|
||||
triple, &type_arena);
|
||||
|
||||
let krate = {
|
||||
let mut v = RustdocVisitor::new(&*ctxt, Some(&analysis));
|
||||
let mut v = RustdocVisitor::new(&ctxt, Some(&analysis));
|
||||
v.visit(&ctxt.krate);
|
||||
v.clean()
|
||||
v.clean(&ctxt)
|
||||
};
|
||||
|
||||
let external_paths = ctxt.external_paths.borrow_mut().take();
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#![feature(globs, struct_variant, managed_boxes, macro_rules, phase)]
|
||||
|
||||
extern crate arena;
|
||||
extern crate debug;
|
||||
extern crate getopts;
|
||||
extern crate libc;
|
||||
@ -29,7 +30,6 @@ extern crate time;
|
||||
|
||||
use std::io;
|
||||
use std::io::{File, MemWriter};
|
||||
use std::gc::Gc;
|
||||
use std::collections::HashMap;
|
||||
use serialize::{json, Decodable, Encodable};
|
||||
use externalfiles::ExternalHtml;
|
||||
@ -83,7 +83,6 @@ static DEFAULT_PASSES: &'static [&'static str] = &[
|
||||
"unindent-comments",
|
||||
];
|
||||
|
||||
local_data_key!(pub ctxtkey: Gc<core::DocContext>)
|
||||
local_data_key!(pub analysiskey: core::CrateAnalysis)
|
||||
|
||||
type Output = (clean::Crate, Vec<plugins::PluginJson> );
|
||||
|
@ -74,7 +74,7 @@ pub fn run(input: &str,
|
||||
"rustdoc-test", None)
|
||||
.expect("phase_2_configure_and_expand aborted in rustdoc!");
|
||||
|
||||
let ctx = box(GC) core::DocContext {
|
||||
let ctx = core::DocContext {
|
||||
krate: krate,
|
||||
maybe_typed: core::NotTyped(sess),
|
||||
src: input_path,
|
||||
@ -84,11 +84,10 @@ pub fn run(input: &str,
|
||||
inlined: RefCell::new(None),
|
||||
populated_crate_impls: RefCell::new(HashSet::new()),
|
||||
};
|
||||
super::ctxtkey.replace(Some(ctx));
|
||||
|
||||
let mut v = RustdocVisitor::new(&*ctx, None);
|
||||
let mut v = RustdocVisitor::new(&ctx, None);
|
||||
v.visit(&ctx.krate);
|
||||
let mut krate = v.clean();
|
||||
let mut krate = v.clean(&ctx);
|
||||
match crate_name {
|
||||
Some(name) => krate.name = name,
|
||||
None => {}
|
||||
|
@ -34,16 +34,16 @@ use doctree::*;
|
||||
// also, is there some reason that this doesn't use the 'visit'
|
||||
// framework from syntax?
|
||||
|
||||
pub struct RustdocVisitor<'a> {
|
||||
pub struct RustdocVisitor<'a, 'tcx: 'a> {
|
||||
pub module: Module,
|
||||
pub attrs: Vec<ast::Attribute>,
|
||||
pub cx: &'a core::DocContext,
|
||||
pub cx: &'a core::DocContext<'tcx>,
|
||||
pub analysis: Option<&'a core::CrateAnalysis>,
|
||||
}
|
||||
|
||||
impl<'a> RustdocVisitor<'a> {
|
||||
pub fn new<'b>(cx: &'b core::DocContext,
|
||||
analysis: Option<&'b core::CrateAnalysis>) -> RustdocVisitor<'b> {
|
||||
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
pub fn new(cx: &'a core::DocContext<'tcx>,
|
||||
analysis: Option<&'a core::CrateAnalysis>) -> RustdocVisitor<'a, 'tcx> {
|
||||
RustdocVisitor {
|
||||
module: Module::new(None),
|
||||
attrs: Vec::new(),
|
||||
@ -53,11 +53,7 @@ impl<'a> RustdocVisitor<'a> {
|
||||
}
|
||||
|
||||
fn stability(&self, id: ast::NodeId) -> Option<attr::Stability> {
|
||||
let tcx = match self.cx.maybe_typed {
|
||||
core::Typed(ref tcx) => tcx,
|
||||
core::NotTyped(_) => return None
|
||||
};
|
||||
stability::lookup(tcx, ast_util::local_def(id))
|
||||
self.cx.tcx_opt().and_then(|tcx| stability::lookup(tcx, ast_util::local_def(id)))
|
||||
}
|
||||
|
||||
pub fn visit(&mut self, krate: &ast::Crate) {
|
||||
@ -225,9 +221,9 @@ impl<'a> RustdocVisitor<'a> {
|
||||
|
||||
fn resolve_id(&mut self, id: ast::NodeId, renamed: Option<ast::Ident>,
|
||||
glob: bool, om: &mut Module, please_inline: bool) -> bool {
|
||||
let tcx = match self.cx.maybe_typed {
|
||||
core::Typed(ref tcx) => tcx,
|
||||
core::NotTyped(_) => return false
|
||||
let tcx = match self.cx.tcx_opt() {
|
||||
Some(tcx) => tcx,
|
||||
None => return false
|
||||
};
|
||||
let def = (*tcx.def_map.borrow())[id].def_id();
|
||||
if !ast_util::is_local(def) { return false }
|
||||
|
Loading…
x
Reference in New Issue
Block a user