Auto merge of #62955 - Mark-Simulacrum:rustdoc-clean-1, r=eddyb
rustdoc: general cleanups This is purely a refactoring, mostly just simplifying some of the code. Commits are best reviewed individually.
This commit is contained in:
commit
9703ef6661
10 changed files with 97 additions and 186 deletions
|
|
@ -58,7 +58,6 @@ use std::path::PathBuf;
|
|||
use std::sync::mpsc;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::mem;
|
||||
|
||||
pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> {
|
||||
sess.diagnostic()
|
||||
|
|
@ -204,15 +203,16 @@ impl ExpansionResult {
|
|||
|
||||
impl BoxedResolver {
|
||||
pub fn to_expansion_result(
|
||||
mut resolver: Rc<Option<RefCell<BoxedResolver>>>,
|
||||
resolver: Rc<RefCell<BoxedResolver>>,
|
||||
) -> ExpansionResult {
|
||||
if let Some(resolver) = Rc::get_mut(&mut resolver) {
|
||||
mem::replace(resolver, None).unwrap().into_inner().complete()
|
||||
} else {
|
||||
let resolver = &*resolver;
|
||||
resolver.as_ref().unwrap().borrow_mut().access(|resolver| {
|
||||
ExpansionResult::from_resolver_ref(resolver)
|
||||
})
|
||||
match Rc::try_unwrap(resolver) {
|
||||
Ok(resolver) => resolver.into_inner().complete(),
|
||||
Err(resolver) => {
|
||||
let resolver = &*resolver;
|
||||
resolver.borrow_mut().access(|resolver| {
|
||||
ExpansionResult::from_resolver_ref(resolver)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ pub(crate) struct Queries {
|
|||
parse: Query<ast::Crate>,
|
||||
crate_name: Query<String>,
|
||||
register_plugins: Query<(ast::Crate, PluginInfo)>,
|
||||
expansion: Query<(ast::Crate, Rc<Option<RefCell<BoxedResolver>>>)>,
|
||||
expansion: Query<(ast::Crate, Steal<Rc<RefCell<BoxedResolver>>>)>,
|
||||
dep_graph: Query<DepGraph>,
|
||||
lower_to_hir: Query<(Steal<hir::map::Forest>, ExpansionResult)>,
|
||||
prepare_outputs: Query<OutputFilenames>,
|
||||
|
|
@ -142,7 +142,7 @@ impl Compiler {
|
|||
|
||||
pub fn expansion(
|
||||
&self
|
||||
) -> Result<&Query<(ast::Crate, Rc<Option<RefCell<BoxedResolver>>>)>> {
|
||||
) -> Result<&Query<(ast::Crate, Steal<Rc<RefCell<BoxedResolver>>>)>> {
|
||||
self.queries.expansion.compute(|| {
|
||||
let crate_name = self.crate_name()?.peek().clone();
|
||||
let (krate, plugin_info) = self.register_plugins()?.take();
|
||||
|
|
@ -152,7 +152,7 @@ impl Compiler {
|
|||
krate,
|
||||
&crate_name,
|
||||
plugin_info,
|
||||
).map(|(krate, resolver)| (krate, Rc::new(Some(RefCell::new(resolver)))))
|
||||
).map(|(krate, resolver)| (krate, Steal::new(Rc::new(RefCell::new(resolver)))))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -176,9 +176,10 @@ impl Compiler {
|
|||
pub fn lower_to_hir(&self) -> Result<&Query<(Steal<hir::map::Forest>, ExpansionResult)>> {
|
||||
self.queries.lower_to_hir.compute(|| {
|
||||
let expansion_result = self.expansion()?;
|
||||
let (krate, resolver) = expansion_result.take();
|
||||
let resolver_ref = &*resolver;
|
||||
let hir = Steal::new(resolver_ref.as_ref().unwrap().borrow_mut().access(|resolver| {
|
||||
let peeked = expansion_result.peek();
|
||||
let krate = &peeked.0;
|
||||
let resolver = peeked.1.steal();
|
||||
let hir = Steal::new(resolver.borrow_mut().access(|resolver| {
|
||||
passes::lower_to_hir(
|
||||
self.session(),
|
||||
self.cstore(),
|
||||
|
|
@ -187,7 +188,6 @@ impl Compiler {
|
|||
&krate
|
||||
)
|
||||
})?);
|
||||
expansion_result.give((krate, Rc::new(None)));
|
||||
Ok((hir, BoxedResolver::to_expansion_result(resolver)))
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ use rustc::ty::subst::Subst;
|
|||
use rustc::infer::InferOk;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
use crate::core::DocAccessLevels;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub struct BlanketImplFinder<'a, 'tcx> {
|
||||
|
|
@ -30,7 +28,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
|||
debug!("get_blanket_impls({:?})", ty);
|
||||
let mut impls = Vec::new();
|
||||
for &trait_def_id in self.cx.all_traits.iter() {
|
||||
if !self.cx.renderinfo.borrow().access_levels.is_doc_reachable(trait_def_id) ||
|
||||
if !self.cx.renderinfo.borrow().access_levels.is_public(trait_def_id) ||
|
||||
self.cx.generated_synthetics
|
||||
.borrow_mut()
|
||||
.get(&(ty, trait_def_id))
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use rustc_metadata::cstore::LoadedMacro;
|
|||
use rustc::ty;
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
|
||||
use crate::core::{DocContext, DocAccessLevels};
|
||||
use crate::core::DocContext;
|
||||
use crate::doctree;
|
||||
use crate::clean::{
|
||||
self,
|
||||
|
|
@ -326,7 +326,7 @@ pub fn build_impl(cx: &DocContext<'_>, did: DefId, attrs: Option<Attrs<'_>>,
|
|||
// reachable in rustdoc generated documentation
|
||||
if !did.is_local() {
|
||||
if let Some(traitref) = associated_trait {
|
||||
if !cx.renderinfo.borrow().access_levels.is_doc_reachable(traitref.def_id) {
|
||||
if !cx.renderinfo.borrow().access_levels.is_public(traitref.def_id) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -347,7 +347,7 @@ pub fn build_impl(cx: &DocContext<'_>, did: DefId, attrs: Option<Attrs<'_>>,
|
|||
// reachable in rustdoc generated documentation
|
||||
if !did.is_local() {
|
||||
if let Some(did) = for_.def_id() {
|
||||
if !cx.renderinfo.borrow().access_levels.is_doc_reachable(did) {
|
||||
if !cx.renderinfo.borrow().access_levels.is_public(did) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,10 +137,15 @@ pub struct Crate {
|
|||
pub masked_crates: FxHashSet<CrateNum>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
|
||||
impl Clean<Crate> for hir::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;
|
||||
|
||||
let v = crate::visit_ast::RustdocVisitor::new(&cx);
|
||||
let module = v.visit(cx.tcx.hir().krate());
|
||||
|
||||
{
|
||||
let mut r = cx.renderinfo.borrow_mut();
|
||||
r.deref_trait_did = cx.tcx.lang_items().deref_trait();
|
||||
|
|
@ -159,7 +163,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
|
|||
|
||||
// Clean the crate, translating the entire libsyntax AST to one that is
|
||||
// understood by rustdoc.
|
||||
let mut module = self.module.as_ref().unwrap().clean(cx);
|
||||
let mut module = module.clean(cx);
|
||||
let mut masked_crates = FxHashSet::default();
|
||||
|
||||
match module.inner {
|
||||
|
|
@ -169,7 +173,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
|
|||
// `#[doc(masked)]` to the injected `extern crate` because it's unstable.
|
||||
if it.is_extern_crate()
|
||||
&& (it.attrs.has_doc_flag(sym::masked)
|
||||
|| self.cx.tcx.is_compiler_builtins(it.def_id.krate))
|
||||
|| cx.tcx.is_compiler_builtins(it.def_id.krate))
|
||||
{
|
||||
masked_crates.insert(it.def_id.krate);
|
||||
}
|
||||
|
|
@ -652,9 +656,9 @@ impl Clean<Item> for doctree::Module<'_> {
|
|||
attrs,
|
||||
source: whence.clean(cx),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_node_id(self.id),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
inner: ModuleItem(Module {
|
||||
is_crate: self.is_crate,
|
||||
items,
|
||||
|
|
@ -1938,8 +1942,8 @@ impl Clean<Item> for doctree::Function<'_> {
|
|||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
def_id: did,
|
||||
inner: FunctionItem(Function {
|
||||
decl,
|
||||
|
|
@ -2138,8 +2142,8 @@ impl Clean<Item> for doctree::Trait<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: TraitItem(Trait {
|
||||
auto: self.is_auto.clean(cx),
|
||||
unsafety: self.unsafety,
|
||||
|
|
@ -2168,8 +2172,8 @@ impl Clean<Item> for doctree::TraitAlias<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: TraitAliasItem(TraitAlias {
|
||||
generics: self.generics.clean(cx),
|
||||
bounds: self.bounds.clean(cx),
|
||||
|
|
@ -3242,8 +3246,8 @@ impl Clean<Item> for doctree::Struct<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: StructItem(Struct {
|
||||
struct_type: self.struct_type,
|
||||
generics: self.generics.clean(cx),
|
||||
|
|
@ -3262,8 +3266,8 @@ impl Clean<Item> for doctree::Union<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: UnionItem(Union {
|
||||
struct_type: self.struct_type,
|
||||
generics: self.generics.clean(cx),
|
||||
|
|
@ -3309,8 +3313,8 @@ impl Clean<Item> for doctree::Enum<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: EnumItem(Enum {
|
||||
variants: self.variants.iter().map(|v| v.clean(cx)).collect(),
|
||||
generics: self.generics.clean(cx),
|
||||
|
|
@ -3332,8 +3336,8 @@ impl Clean<Item> for doctree::Variant<'_> {
|
|||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
visibility: None,
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
inner: VariantItem(Variant {
|
||||
kind: self.def.clean(cx),
|
||||
|
|
@ -3637,8 +3641,8 @@ impl Clean<Item> for doctree::Typedef<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: TypedefItem(Typedef {
|
||||
type_: self.ty.clean(cx),
|
||||
generics: self.gen.clean(cx),
|
||||
|
|
@ -3661,8 +3665,8 @@ impl Clean<Item> for doctree::OpaqueTy<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: OpaqueTyItem(OpaqueTy {
|
||||
bounds: self.opaque_ty.bounds.clean(cx),
|
||||
generics: self.opaque_ty.generics.clean(cx),
|
||||
|
|
@ -3712,8 +3716,8 @@ impl Clean<Item> for doctree::Static<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: StaticItem(Static {
|
||||
type_: self.type_.clean(cx),
|
||||
mutability: self.mutability.clean(cx),
|
||||
|
|
@ -3737,8 +3741,8 @@ impl Clean<Item> for doctree::Constant<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: ConstantItem(Constant {
|
||||
type_: self.type_.clean(cx),
|
||||
expr: print_const_expr(cx, self.expr),
|
||||
|
|
@ -3824,8 +3828,8 @@ impl Clean<Vec<Item>> for doctree::Impl<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: ImplItem(Impl {
|
||||
unsafety: self.unsafety,
|
||||
generics: self.generics.clean(cx),
|
||||
|
|
@ -4063,8 +4067,8 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
|
|||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner,
|
||||
}
|
||||
}
|
||||
|
|
@ -4246,8 +4250,8 @@ impl Clean<Item> for doctree::Macro<'_> {
|
|||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
visibility: Some(Public),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.hid).clean(cx),
|
||||
deprecation: cx.deprecation(self.hid).clean(cx),
|
||||
def_id: self.def_id,
|
||||
inner: MacroItem(Macro {
|
||||
source: format!("macro_rules! {} {{\n{}}}",
|
||||
|
|
@ -4274,8 +4278,8 @@ impl Clean<Item> for doctree::ProcMacro<'_> {
|
|||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
visibility: Some(Public),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
stability: cx.stability(self.id).clean(cx),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
inner: ProcMacroItem(ProcMacro {
|
||||
kind: self.kind,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use rustc_metadata::cstore::CStore;
|
|||
use rustc_target::spec::TargetTriple;
|
||||
|
||||
use syntax::source_map;
|
||||
use syntax::attr;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
use syntax::json::JsonEmitter;
|
||||
use syntax::symbol::sym;
|
||||
|
|
@ -29,7 +30,6 @@ use rustc_data_structures::sync::{self, Lrc};
|
|||
use std::sync::Arc;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::visit_ast::RustdocVisitor;
|
||||
use crate::config::{Options as RustdocOptions, RenderOptions};
|
||||
use crate::clean;
|
||||
use crate::clean::{Clean, MAX_DEF_ID, AttributesExt};
|
||||
|
|
@ -45,7 +45,7 @@ pub type ExternalPaths = FxHashMap<DefId, (Vec<String>, clean::TypeKind)>;
|
|||
pub struct DocContext<'tcx> {
|
||||
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
pub resolver: Rc<Option<RefCell<interface::BoxedResolver>>>,
|
||||
pub resolver: Rc<RefCell<interface::BoxedResolver>>,
|
||||
/// The stack of module NodeIds up till this point
|
||||
pub crate_name: Option<String>,
|
||||
pub cstore: Lrc<CStore>,
|
||||
|
|
@ -83,9 +83,7 @@ impl<'tcx> DocContext<'tcx> {
|
|||
|
||||
pub fn enter_resolver<F, R>(&self, f: F) -> R
|
||||
where F: FnOnce(&mut resolve::Resolver<'_>) -> R {
|
||||
let resolver = &*self.resolver;
|
||||
let resolver = resolver.as_ref().unwrap();
|
||||
resolver.borrow_mut().access(f)
|
||||
self.resolver.borrow_mut().access(f)
|
||||
}
|
||||
|
||||
/// Call the closure with the given parameters set as
|
||||
|
|
@ -167,15 +165,15 @@ impl<'tcx> DocContext<'tcx> {
|
|||
self.tcx.hir().as_local_hir_id(def_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait DocAccessLevels {
|
||||
fn is_doc_reachable(&self, did: DefId) -> bool;
|
||||
}
|
||||
pub fn stability(&self, id: HirId) -> Option<attr::Stability> {
|
||||
self.tcx.hir().opt_local_def_id(id)
|
||||
.and_then(|def_id| self.tcx.lookup_stability(def_id)).cloned()
|
||||
}
|
||||
|
||||
impl DocAccessLevels for AccessLevels<DefId> {
|
||||
fn is_doc_reachable(&self, did: DefId) -> bool {
|
||||
self.is_public(did)
|
||||
pub fn deprecation(&self, id: HirId) -> Option<attr::Deprecation> {
|
||||
self.tcx.hir().opt_local_def_id(id)
|
||||
.and_then(|def_id| self.tcx.lookup_deprecation(def_id))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +342,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
|||
// We need to hold on to the complete resolver, so we cause everything to be
|
||||
// cloned for the analysis passes to use. Suboptimal, but necessary in the
|
||||
// current architecture.
|
||||
let resolver = abort_on_err(compiler.expansion(), sess).peek().1.clone();
|
||||
let resolver = abort_on_err(compiler.expansion(), sess).peek().1.borrow().clone();
|
||||
|
||||
if sess.has_errors() {
|
||||
sess.fatal("Compilation failed, aborting rustdoc");
|
||||
|
|
@ -393,11 +391,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
|||
};
|
||||
debug!("crate: {:?}", tcx.hir().krate());
|
||||
|
||||
let mut krate = {
|
||||
let mut v = RustdocVisitor::new(&ctxt);
|
||||
v.visit(tcx.hir().krate());
|
||||
v.clean(&ctxt)
|
||||
};
|
||||
let mut krate = tcx.hir().krate().clean(&ctxt);
|
||||
|
||||
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
|
||||
let mut msg = diag.struct_warn(&format!("the `#![doc({})]` attribute is \
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
pub use self::StructType::*;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::ast::{Name, NodeId};
|
||||
use syntax::attr;
|
||||
use syntax::ast::Name;
|
||||
use syntax::ext::base::MacroKind;
|
||||
use syntax_pos::{self, Span};
|
||||
|
||||
|
|
@ -24,15 +23,13 @@ pub struct Module<'hir> {
|
|||
pub enums: Vec<Enum<'hir>>,
|
||||
pub fns: Vec<Function<'hir>>,
|
||||
pub mods: Vec<Module<'hir>>,
|
||||
pub id: NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub typedefs: Vec<Typedef<'hir>>,
|
||||
pub opaque_tys: Vec<OpaqueTy<'hir>>,
|
||||
pub statics: Vec<Static<'hir>>,
|
||||
pub constants: Vec<Constant<'hir>>,
|
||||
pub traits: Vec<Trait<'hir>>,
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub impls: Vec<Impl<'hir>>,
|
||||
pub foreigns: Vec<ForeignItem<'hir>>,
|
||||
pub macros: Vec<Macro<'hir>>,
|
||||
|
|
@ -49,10 +46,8 @@ impl Module<'hir> {
|
|||
) -> Module<'hir> {
|
||||
Module {
|
||||
name : name,
|
||||
id: ast::CRATE_NODE_ID,
|
||||
id: hir::CRATE_HIR_ID,
|
||||
vis,
|
||||
stab: None,
|
||||
depr: None,
|
||||
where_outer: syntax_pos::DUMMY_SP,
|
||||
where_inner: syntax_pos::DUMMY_SP,
|
||||
attrs,
|
||||
|
|
@ -90,8 +85,6 @@ pub enum StructType {
|
|||
|
||||
pub struct Struct<'hir> {
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: hir::HirId,
|
||||
pub struct_type: StructType,
|
||||
pub name: Name,
|
||||
|
|
@ -103,8 +96,6 @@ pub struct Struct<'hir> {
|
|||
|
||||
pub struct Union<'hir> {
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: hir::HirId,
|
||||
pub struct_type: StructType,
|
||||
pub name: Name,
|
||||
|
|
@ -116,8 +107,6 @@ pub struct Union<'hir> {
|
|||
|
||||
pub struct Enum<'hir> {
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub variants: Vec<Variant<'hir>>,
|
||||
pub generics: &'hir hir::Generics,
|
||||
pub attrs: &'hir hir::HirVec<ast::Attribute>,
|
||||
|
|
@ -131,8 +120,6 @@ pub struct Variant<'hir> {
|
|||
pub id: hir::HirId,
|
||||
pub attrs: &'hir hir::HirVec<ast::Attribute>,
|
||||
pub def: &'hir hir::VariantData,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub whence: Span,
|
||||
}
|
||||
|
||||
|
|
@ -142,8 +129,6 @@ pub struct Function<'hir> {
|
|||
pub id: hir::HirId,
|
||||
pub name: Name,
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub header: hir::FnHeader,
|
||||
pub whence: Span,
|
||||
pub generics: &'hir hir::Generics,
|
||||
|
|
@ -158,8 +143,6 @@ pub struct Typedef<'hir> {
|
|||
pub attrs: &'hir hir::HirVec<ast::Attribute>,
|
||||
pub whence: Span,
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
}
|
||||
|
||||
pub struct OpaqueTy<'hir> {
|
||||
|
|
@ -169,8 +152,6 @@ pub struct OpaqueTy<'hir> {
|
|||
pub attrs: &'hir hir::HirVec<ast::Attribute>,
|
||||
pub whence: Span,
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -181,8 +162,6 @@ pub struct Static<'hir> {
|
|||
pub name: Name,
|
||||
pub attrs: &'hir hir::HirVec<ast::Attribute>,
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: hir::HirId,
|
||||
pub whence: Span,
|
||||
}
|
||||
|
|
@ -193,8 +172,6 @@ pub struct Constant<'hir> {
|
|||
pub name: Name,
|
||||
pub attrs: &'hir hir::HirVec<ast::Attribute>,
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: hir::HirId,
|
||||
pub whence: Span,
|
||||
}
|
||||
|
|
@ -210,8 +187,6 @@ pub struct Trait<'hir> {
|
|||
pub id: hir::HirId,
|
||||
pub whence: Span,
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
}
|
||||
|
||||
pub struct TraitAlias<'hir> {
|
||||
|
|
@ -222,8 +197,6 @@ pub struct TraitAlias<'hir> {
|
|||
pub id: hir::HirId,
|
||||
pub whence: Span,
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -238,15 +211,11 @@ pub struct Impl<'hir> {
|
|||
pub attrs: &'hir hir::HirVec<ast::Attribute>,
|
||||
pub whence: Span,
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: hir::HirId,
|
||||
}
|
||||
|
||||
pub struct ForeignItem<'hir> {
|
||||
pub vis: &'hir hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: hir::HirId,
|
||||
pub name: Name,
|
||||
pub kind: &'hir hir::ForeignItemKind,
|
||||
|
|
@ -258,12 +227,11 @@ pub struct ForeignItem<'hir> {
|
|||
// these imported macro_rules (which only have a DUMMY_NODE_ID).
|
||||
pub struct Macro<'hir> {
|
||||
pub name: Name,
|
||||
pub hid: hir::HirId,
|
||||
pub def_id: hir::def_id::DefId,
|
||||
pub attrs: &'hir hir::HirVec<ast::Attribute>,
|
||||
pub whence: Span,
|
||||
pub matchers: hir::HirVec<Span>,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub imported_from: Option<Name>,
|
||||
}
|
||||
|
||||
|
|
@ -293,8 +261,6 @@ pub struct ProcMacro<'hir> {
|
|||
pub helpers: Vec<Name>,
|
||||
pub attrs: &'hir hir::HirVec<ast::Attribute>,
|
||||
pub whence: Span,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
}
|
||||
|
||||
pub fn struct_type_from_def(vdata: &hir::VariantData) -> StructType {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ use rustc_target::spec::abi::Abi;
|
|||
use rustc::hir;
|
||||
|
||||
use crate::clean::{self, PrimitiveType};
|
||||
use crate::core::DocAccessLevels;
|
||||
use crate::html::item_type::ItemType;
|
||||
use crate::html::render::{self, cache, CURRENT_LOCATION_KEY};
|
||||
|
||||
|
|
@ -404,7 +403,7 @@ impl fmt::Display for clean::Path {
|
|||
|
||||
pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
|
||||
let cache = cache();
|
||||
if !did.is_local() && !cache.access_levels.is_doc_reachable(did) {
|
||||
if !did.is_local() && !cache.access_levels.is_public(did) {
|
||||
return None
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use syntax_pos::{DUMMY_SP, InnerSpan, Span};
|
|||
use std::ops::Range;
|
||||
|
||||
use crate::clean::{self, GetDefId, Item};
|
||||
use crate::core::{DocContext, DocAccessLevels};
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::{DocFolder, StripItem};
|
||||
use crate::html::markdown::{find_testable_code, ErrorCodes, LangString};
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ pub fn look_for_tests<'tcx>(
|
|||
diag.emit();
|
||||
} else if check_missing_code == false &&
|
||||
tests.found_tests > 0 &&
|
||||
!cx.renderinfo.borrow().access_levels.is_doc_reachable(item.def_id) {
|
||||
!cx.renderinfo.borrow().access_levels.is_public(item.def_id) {
|
||||
let mut diag = cx.tcx.struct_span_lint_hir(
|
||||
lint::builtin::PRIVATE_DOC_TESTS,
|
||||
hir_id,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
|||
use rustc::middle::privacy::AccessLevel;
|
||||
use rustc::util::nodemap::{FxHashSet, FxHashMap};
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::ext::base::MacroKind;
|
||||
use syntax::source_map::Spanned;
|
||||
use syntax::symbol::sym;
|
||||
|
|
@ -20,22 +19,16 @@ use crate::clean::{self, AttributesExt, NestedAttributesExt, def_id_to_path};
|
|||
use crate::doctree::*;
|
||||
|
||||
|
||||
// Looks to me like the first two of these are actually
|
||||
// output parameters, maybe only mutated once; perhaps
|
||||
// better simply to have the visit method return a tuple
|
||||
// containing them?
|
||||
|
||||
// Also, is there some reason that this doesn't use the 'visit'
|
||||
// framework from syntax?.
|
||||
|
||||
pub struct RustdocVisitor<'a, 'tcx> {
|
||||
pub module: Option<Module<'tcx>>,
|
||||
pub cx: &'a core::DocContext<'tcx>,
|
||||
cx: &'a core::DocContext<'tcx>,
|
||||
view_item_stack: FxHashSet<hir::HirId>,
|
||||
inlining: bool,
|
||||
/// Are the current module and all of its parents public?
|
||||
inside_public_path: bool,
|
||||
exact_paths: Option<FxHashMap<DefId, Vec<String>>>,
|
||||
exact_paths: FxHashMap<DefId, Vec<String>>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
|
|
@ -46,36 +39,24 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
let mut stack = FxHashSet::default();
|
||||
stack.insert(hir::CRATE_HIR_ID);
|
||||
RustdocVisitor {
|
||||
module: None,
|
||||
cx,
|
||||
view_item_stack: stack,
|
||||
inlining: false,
|
||||
inside_public_path: true,
|
||||
exact_paths: Some(FxHashMap::default()),
|
||||
exact_paths: FxHashMap::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn store_path(&mut self, did: DefId) {
|
||||
// We can't use the entry API, as that keeps the mutable borrow of `self` active
|
||||
// when we try to use `cx`.
|
||||
let exact_paths = self.exact_paths.as_mut().unwrap();
|
||||
if exact_paths.get(&did).is_none() {
|
||||
if self.exact_paths.get(&did).is_none() {
|
||||
let path = def_id_to_path(self.cx, did, self.cx.crate_name.clone());
|
||||
exact_paths.insert(did, path);
|
||||
self.exact_paths.insert(did, path);
|
||||
}
|
||||
}
|
||||
|
||||
fn stability(&self, id: hir::HirId) -> Option<attr::Stability> {
|
||||
self.cx.tcx.hir().opt_local_def_id(id)
|
||||
.and_then(|def_id| self.cx.tcx.lookup_stability(def_id)).cloned()
|
||||
}
|
||||
|
||||
fn deprecation(&self, id: hir::HirId) -> Option<attr::Deprecation> {
|
||||
self.cx.tcx.hir().opt_local_def_id(id)
|
||||
.and_then(|def_id| self.cx.tcx.lookup_deprecation(def_id))
|
||||
}
|
||||
|
||||
pub fn visit(&mut self, krate: &'tcx hir::Crate) {
|
||||
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,
|
||||
|
|
@ -88,12 +69,13 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
krate.exported_macros.iter().map(|def| self.visit_local_macro(def, None)),
|
||||
);
|
||||
module.is_crate = true;
|
||||
self.module = Some(module);
|
||||
|
||||
self.cx.renderinfo.borrow_mut().exact_paths = self.exact_paths.take().unwrap();
|
||||
self.cx.renderinfo.borrow_mut().exact_paths = self.exact_paths;
|
||||
|
||||
module
|
||||
}
|
||||
|
||||
pub fn visit_variant_data(&mut self, item: &'tcx hir::Item,
|
||||
fn visit_variant_data(&mut self, item: &'tcx hir::Item,
|
||||
name: ast::Name, sd: &'tcx hir::VariantData,
|
||||
generics: &'tcx hir::Generics) -> Struct<'tcx> {
|
||||
debug!("visiting struct");
|
||||
|
|
@ -103,8 +85,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
struct_type,
|
||||
name,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
attrs: &item.attrs,
|
||||
generics,
|
||||
fields: sd.fields(),
|
||||
|
|
@ -112,7 +92,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_union_data(&mut self, item: &'tcx hir::Item,
|
||||
fn visit_union_data(&mut self, item: &'tcx hir::Item,
|
||||
name: ast::Name, sd: &'tcx hir::VariantData,
|
||||
generics: &'tcx hir::Generics) -> Union<'tcx> {
|
||||
debug!("visiting union");
|
||||
|
|
@ -122,8 +102,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
struct_type,
|
||||
name,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
attrs: &item.attrs,
|
||||
generics,
|
||||
fields: sd.fields(),
|
||||
|
|
@ -131,7 +109,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_enum_def(&mut self, it: &'tcx hir::Item,
|
||||
fn visit_enum_def(&mut self, it: &'tcx hir::Item,
|
||||
name: ast::Name, def: &'tcx hir::EnumDef,
|
||||
generics: &'tcx hir::Generics) -> Enum<'tcx> {
|
||||
debug!("visiting enum");
|
||||
|
|
@ -141,14 +119,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
name: v.node.ident.name,
|
||||
id: v.node.id,
|
||||
attrs: &v.node.attrs,
|
||||
stab: self.stability(v.node.id),
|
||||
depr: self.deprecation(v.node.id),
|
||||
def: &v.node.data,
|
||||
whence: v.span,
|
||||
}).collect(),
|
||||
vis: &it.vis,
|
||||
stab: self.stability(it.hir_id),
|
||||
depr: self.deprecation(it.hir_id),
|
||||
generics,
|
||||
attrs: &it.attrs,
|
||||
id: it.hir_id,
|
||||
|
|
@ -156,7 +130,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_fn(&mut self, om: &mut Module<'tcx>, item: &'tcx hir::Item,
|
||||
fn visit_fn(&mut self, om: &mut Module<'tcx>, item: &'tcx hir::Item,
|
||||
name: ast::Name, decl: &'tcx hir::FnDecl,
|
||||
header: hir::FnHeader,
|
||||
generics: &'tcx hir::Generics,
|
||||
|
|
@ -207,16 +181,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
helpers,
|
||||
attrs: &item.attrs,
|
||||
whence: item.span,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
});
|
||||
}
|
||||
None => {
|
||||
om.fns.push(Function {
|
||||
id: item.hir_id,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
attrs: &item.attrs,
|
||||
decl,
|
||||
name,
|
||||
|
|
@ -229,16 +199,14 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_mod_contents(&mut self, span: Span, attrs: &'tcx hir::HirVec<ast::Attribute>,
|
||||
fn visit_mod_contents(&mut self, span: Span, attrs: &'tcx hir::HirVec<ast::Attribute>,
|
||||
vis: &'tcx hir::Visibility, id: hir::HirId,
|
||||
m: &'tcx hir::Mod,
|
||||
name: Option<ast::Name>) -> Module<'tcx> {
|
||||
let mut om = Module::new(name, attrs, vis);
|
||||
om.where_outer = span;
|
||||
om.where_inner = m.inner;
|
||||
om.stab = self.stability(id);
|
||||
om.depr = self.deprecation(id);
|
||||
om.id = self.cx.tcx.hir().hir_to_node_id(id);
|
||||
om.id = id;
|
||||
// Keep track of if there were any private modules in the path.
|
||||
let orig_inside_public_path = self.inside_public_path;
|
||||
self.inside_public_path &= vis.node.is_pub();
|
||||
|
|
@ -369,7 +337,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
ret
|
||||
}
|
||||
|
||||
pub fn visit_item(&mut self, item: &'tcx hir::Item,
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item,
|
||||
renamed: Option<ast::Ident>, om: &mut Module<'tcx>) {
|
||||
debug!("visiting item {:?}", item);
|
||||
let ident = renamed.unwrap_or(item.ident);
|
||||
|
|
@ -467,8 +435,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
attrs: &item.attrs,
|
||||
whence: item.span,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
};
|
||||
om.typedefs.push(t);
|
||||
},
|
||||
|
|
@ -480,8 +446,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
attrs: &item.attrs,
|
||||
whence: item.span,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
};
|
||||
om.opaque_tys.push(t);
|
||||
},
|
||||
|
|
@ -495,8 +459,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
attrs: &item.attrs,
|
||||
whence: item.span,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
};
|
||||
om.statics.push(s);
|
||||
},
|
||||
|
|
@ -509,8 +471,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
attrs: &item.attrs,
|
||||
whence: item.span,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
};
|
||||
om.constants.push(s);
|
||||
},
|
||||
|
|
@ -529,8 +489,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
attrs: &item.attrs,
|
||||
whence: item.span,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
};
|
||||
om.traits.push(t);
|
||||
},
|
||||
|
|
@ -543,8 +501,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
attrs: &item.attrs,
|
||||
whence: item.span,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
};
|
||||
om.trait_aliases.push(t);
|
||||
},
|
||||
|
|
@ -574,8 +530,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
id: item.hir_id,
|
||||
whence: item.span,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
};
|
||||
om.impls.push(i);
|
||||
}
|
||||
|
|
@ -595,8 +549,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
name: renamed.unwrap_or(item.ident).name,
|
||||
kind: &item.node,
|
||||
vis: &item.vis,
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
attrs: &item.attrs,
|
||||
whence: item.span
|
||||
});
|
||||
|
|
@ -614,14 +566,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
let matchers = tts.chunks(4).map(|arm| arm[0].span()).collect();
|
||||
|
||||
Macro {
|
||||
|
||||
hid: def.hir_id,
|
||||
def_id: self.cx.tcx.hir().local_def_id(def.hir_id),
|
||||
attrs: &def.attrs,
|
||||
name: renamed.unwrap_or(def.name),
|
||||
whence: def.span,
|
||||
matchers,
|
||||
stab: self.stability(def.hir_id),
|
||||
depr: self.deprecation(def.hir_id),
|
||||
imported_from: None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue