mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-10 19:16:51 +00:00
Fix fallout in rustdoc
This commit is contained in:
parent
1e5942469d
commit
3bf9fc0c2a
@ -122,7 +122,7 @@ fn try_inline_def(cx: &DocContext, tcx: &TyCtxt,
|
||||
name: Some(tcx.item_name(did).to_string()),
|
||||
attrs: load_attrs(cx, tcx, did),
|
||||
inner: inner,
|
||||
visibility: Some(hir::Public),
|
||||
visibility: Some(clean::Public),
|
||||
stability: stability::lookup_stability(tcx, did).clean(cx),
|
||||
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
|
||||
def_id: did,
|
||||
@ -323,7 +323,7 @@ pub fn build_impl(cx: &DocContext,
|
||||
source: clean::Span::empty(),
|
||||
name: None,
|
||||
attrs: attrs,
|
||||
visibility: Some(hir::Inherited),
|
||||
visibility: Some(clean::Inherited),
|
||||
stability: stability::lookup_stability(tcx, did).clean(cx),
|
||||
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
|
||||
def_id: did,
|
||||
@ -444,7 +444,7 @@ pub fn build_impl(cx: &DocContext,
|
||||
source: clean::Span::empty(),
|
||||
name: None,
|
||||
attrs: attrs,
|
||||
visibility: Some(hir::Inherited),
|
||||
visibility: Some(clean::Inherited),
|
||||
stability: stability::lookup_stability(tcx, did).clean(cx),
|
||||
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
|
||||
def_id: did,
|
||||
|
@ -22,6 +22,7 @@ pub use self::Attribute::*;
|
||||
pub use self::TyParamBound::*;
|
||||
pub use self::SelfTy::*;
|
||||
pub use self::FunctionRetTy::*;
|
||||
pub use self::Visibility::*;
|
||||
|
||||
use syntax;
|
||||
use syntax::abi::Abi;
|
||||
@ -183,7 +184,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
|
||||
source: Span::empty(),
|
||||
name: Some(prim.to_url_str().to_string()),
|
||||
attrs: child.attrs.clone(),
|
||||
visibility: Some(hir::Public),
|
||||
visibility: Some(Public),
|
||||
stability: None,
|
||||
deprecation: None,
|
||||
def_id: DefId::local(prim.to_def_index()),
|
||||
@ -1391,7 +1392,7 @@ impl<'tcx> Clean<Item> for ty::Method<'tcx> {
|
||||
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
visibility: Some(hir::Inherited),
|
||||
visibility: Some(Inherited),
|
||||
stability: get_stability(cx, self.def_id),
|
||||
deprecation: get_deprecation(cx, self.def_id),
|
||||
def_id: self.def_id,
|
||||
@ -1777,17 +1778,21 @@ impl<'tcx> Clean<Item> for ty::FieldDefData<'tcx, 'static> {
|
||||
}
|
||||
}
|
||||
|
||||
pub type Visibility = hir::Visibility;
|
||||
#[derive(Clone, PartialEq, Eq, RustcDecodable, RustcEncodable, Debug)]
|
||||
pub enum Visibility {
|
||||
Public,
|
||||
Inherited,
|
||||
}
|
||||
|
||||
impl Clean<Option<Visibility>> for hir::Visibility {
|
||||
fn clean(&self, _: &DocContext) -> Option<Visibility> {
|
||||
Some(self.clone())
|
||||
Some(if *self == hir::Visibility::Public { Public } else { Inherited })
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<Option<Visibility>> for ty::Visibility {
|
||||
fn clean(&self, _: &DocContext) -> Option<Visibility> {
|
||||
Some(if *self == ty::Visibility::Public { hir::Public } else { hir::Inherited })
|
||||
Some(if *self == ty::Visibility::Public { Public } else { Inherited })
|
||||
}
|
||||
}
|
||||
|
||||
@ -1919,7 +1924,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: inline::load_attrs(cx, cx.tcx(), self.did),
|
||||
source: Span::empty(),
|
||||
visibility: Some(hir::Inherited),
|
||||
visibility: Some(Inherited),
|
||||
def_id: self.did,
|
||||
inner: VariantItem(Variant { kind: kind }),
|
||||
stability: get_stability(cx, self.did),
|
||||
@ -2341,7 +2346,7 @@ impl Clean<Item> for doctree::DefaultImpl {
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.map.local_def_id(self.id),
|
||||
visibility: Some(hir::Public),
|
||||
visibility: Some(Public),
|
||||
stability: None,
|
||||
deprecation: None,
|
||||
inner: DefaultImplItem(DefaultImpl {
|
||||
@ -2700,7 +2705,7 @@ impl Clean<Item> for doctree::Macro {
|
||||
name: Some(name.clone()),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
visibility: hir::Public.clean(cx),
|
||||
visibility: Some(Public),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
def_id: cx.map.local_def_id(self.id),
|
||||
|
@ -31,7 +31,7 @@ use html::render::{cache, CURRENT_LOCATION_KEY};
|
||||
/// Helper to render an optional visibility with a space after it (if the
|
||||
/// visibility is preset)
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct VisSpace<'a>(pub &'a Option<hir::Visibility>);
|
||||
pub struct VisSpace<'a>(pub &'a Option<clean::Visibility>);
|
||||
/// Similarly to VisSpace, this structure is used to render a function style with a
|
||||
/// space after it.
|
||||
#[derive(Copy, Clone)]
|
||||
@ -57,7 +57,7 @@ pub struct CommaSep<'a, T: 'a>(pub &'a [T]);
|
||||
pub struct AbiSpace(pub Abi);
|
||||
|
||||
impl<'a> VisSpace<'a> {
|
||||
pub fn get(self) -> &'a Option<hir::Visibility> {
|
||||
pub fn get(self) -> &'a Option<clean::Visibility> {
|
||||
let VisSpace(v) = self; v
|
||||
}
|
||||
}
|
||||
@ -639,8 +639,8 @@ impl<'a> fmt::Display for Method<'a> {
|
||||
impl<'a> fmt::Display for VisSpace<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self.get() {
|
||||
Some(hir::Public) => write!(f, "pub "),
|
||||
Some(hir::Inherited) | None => Ok(())
|
||||
Some(clean::Public) => write!(f, "pub "),
|
||||
Some(clean::Inherited) | None => Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1408,7 +1408,8 @@ impl Context {
|
||||
match it.inner {
|
||||
clean::StrippedItem(..) => true,
|
||||
clean::ModuleItem(ref m) => {
|
||||
it.doc_value().is_none() && m.items.is_empty() && it.visibility != Some(hir::Public)
|
||||
it.doc_value().is_none() && m.items.is_empty()
|
||||
&& it.visibility != Some(clean::Public)
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ use rustc::util::nodemap::DefIdSet;
|
||||
use std::cmp;
|
||||
use std::string::String;
|
||||
use std::usize;
|
||||
use rustc::hir;
|
||||
|
||||
use clean::{self, Attributes, GetDefId};
|
||||
use clean::Item;
|
||||
@ -133,13 +132,13 @@ impl<'a> fold::DocFolder for Stripper<'a> {
|
||||
}
|
||||
|
||||
clean::StructFieldItem(..) => {
|
||||
if i.visibility != Some(hir::Public) {
|
||||
if i.visibility != Some(clean::Public) {
|
||||
return Strip(i).fold();
|
||||
}
|
||||
}
|
||||
|
||||
clean::ModuleItem(..) => {
|
||||
if i.def_id.is_local() && i.visibility != Some(hir::Public) {
|
||||
if i.def_id.is_local() && i.visibility != Some(clean::Public) {
|
||||
return Strip(self.fold_item_recur(i).unwrap()).fold()
|
||||
}
|
||||
}
|
||||
@ -226,7 +225,7 @@ impl fold::DocFolder for ImportStripper {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
match i.inner {
|
||||
clean::ExternCrateItem(..) |
|
||||
clean::ImportItem(..) if i.visibility != Some(hir::Public) => None,
|
||||
clean::ImportItem(..) if i.visibility != Some(clean::Public) => None,
|
||||
_ => self.fold_item_recur(i)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user