Skip to content

Commit 3bf9fc0

Browse files
committed
Fix fallout in rustdoc
1 parent 1e59424 commit 3bf9fc0

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

src/librustdoc/clean/inline.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn try_inline_def(cx: &DocContext, tcx: &TyCtxt,
122122
name: Some(tcx.item_name(did).to_string()),
123123
attrs: load_attrs(cx, tcx, did),
124124
inner: inner,
125-
visibility: Some(hir::Public),
125+
visibility: Some(clean::Public),
126126
stability: stability::lookup_stability(tcx, did).clean(cx),
127127
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
128128
def_id: did,
@@ -323,7 +323,7 @@ pub fn build_impl(cx: &DocContext,
323323
source: clean::Span::empty(),
324324
name: None,
325325
attrs: attrs,
326-
visibility: Some(hir::Inherited),
326+
visibility: Some(clean::Inherited),
327327
stability: stability::lookup_stability(tcx, did).clean(cx),
328328
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
329329
def_id: did,
@@ -444,7 +444,7 @@ pub fn build_impl(cx: &DocContext,
444444
source: clean::Span::empty(),
445445
name: None,
446446
attrs: attrs,
447-
visibility: Some(hir::Inherited),
447+
visibility: Some(clean::Inherited),
448448
stability: stability::lookup_stability(tcx, did).clean(cx),
449449
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
450450
def_id: did,

src/librustdoc/clean/mod.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub use self::Attribute::*;
2222
pub use self::TyParamBound::*;
2323
pub use self::SelfTy::*;
2424
pub use self::FunctionRetTy::*;
25+
pub use self::Visibility::*;
2526

2627
use syntax;
2728
use syntax::abi::Abi;
@@ -183,7 +184,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
183184
source: Span::empty(),
184185
name: Some(prim.to_url_str().to_string()),
185186
attrs: child.attrs.clone(),
186-
visibility: Some(hir::Public),
187+
visibility: Some(Public),
187188
stability: None,
188189
deprecation: None,
189190
def_id: DefId::local(prim.to_def_index()),
@@ -1391,7 +1392,7 @@ impl<'tcx> Clean<Item> for ty::Method<'tcx> {
13911392

13921393
Item {
13931394
name: Some(self.name.clean(cx)),
1394-
visibility: Some(hir::Inherited),
1395+
visibility: Some(Inherited),
13951396
stability: get_stability(cx, self.def_id),
13961397
deprecation: get_deprecation(cx, self.def_id),
13971398
def_id: self.def_id,
@@ -1777,17 +1778,21 @@ impl<'tcx> Clean<Item> for ty::FieldDefData<'tcx, 'static> {
17771778
}
17781779
}
17791780

1780-
pub type Visibility = hir::Visibility;
1781+
#[derive(Clone, PartialEq, Eq, RustcDecodable, RustcEncodable, Debug)]
1782+
pub enum Visibility {
1783+
Public,
1784+
Inherited,
1785+
}
17811786

17821787
impl Clean<Option<Visibility>> for hir::Visibility {
17831788
fn clean(&self, _: &DocContext) -> Option<Visibility> {
1784-
Some(self.clone())
1789+
Some(if *self == hir::Visibility::Public { Public } else { Inherited })
17851790
}
17861791
}
17871792

17881793
impl Clean<Option<Visibility>> for ty::Visibility {
17891794
fn clean(&self, _: &DocContext) -> Option<Visibility> {
1790-
Some(if *self == ty::Visibility::Public { hir::Public } else { hir::Inherited })
1795+
Some(if *self == ty::Visibility::Public { Public } else { Inherited })
17911796
}
17921797
}
17931798

@@ -1919,7 +1924,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
19191924
name: Some(self.name.clean(cx)),
19201925
attrs: inline::load_attrs(cx, cx.tcx(), self.did),
19211926
source: Span::empty(),
1922-
visibility: Some(hir::Inherited),
1927+
visibility: Some(Inherited),
19231928
def_id: self.did,
19241929
inner: VariantItem(Variant { kind: kind }),
19251930
stability: get_stability(cx, self.did),
@@ -2341,7 +2346,7 @@ impl Clean<Item> for doctree::DefaultImpl {
23412346
attrs: self.attrs.clean(cx),
23422347
source: self.whence.clean(cx),
23432348
def_id: cx.map.local_def_id(self.id),
2344-
visibility: Some(hir::Public),
2349+
visibility: Some(Public),
23452350
stability: None,
23462351
deprecation: None,
23472352
inner: DefaultImplItem(DefaultImpl {
@@ -2700,7 +2705,7 @@ impl Clean<Item> for doctree::Macro {
27002705
name: Some(name.clone()),
27012706
attrs: self.attrs.clean(cx),
27022707
source: self.whence.clean(cx),
2703-
visibility: hir::Public.clean(cx),
2708+
visibility: Some(Public),
27042709
stability: self.stab.clean(cx),
27052710
deprecation: self.depr.clean(cx),
27062711
def_id: cx.map.local_def_id(self.id),

src/librustdoc/html/format.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use html::render::{cache, CURRENT_LOCATION_KEY};
3131
/// Helper to render an optional visibility with a space after it (if the
3232
/// visibility is preset)
3333
#[derive(Copy, Clone)]
34-
pub struct VisSpace<'a>(pub &'a Option<hir::Visibility>);
34+
pub struct VisSpace<'a>(pub &'a Option<clean::Visibility>);
3535
/// Similarly to VisSpace, this structure is used to render a function style with a
3636
/// space after it.
3737
#[derive(Copy, Clone)]
@@ -57,7 +57,7 @@ pub struct CommaSep<'a, T: 'a>(pub &'a [T]);
5757
pub struct AbiSpace(pub Abi);
5858

5959
impl<'a> VisSpace<'a> {
60-
pub fn get(self) -> &'a Option<hir::Visibility> {
60+
pub fn get(self) -> &'a Option<clean::Visibility> {
6161
let VisSpace(v) = self; v
6262
}
6363
}
@@ -639,8 +639,8 @@ impl<'a> fmt::Display for Method<'a> {
639639
impl<'a> fmt::Display for VisSpace<'a> {
640640
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
641641
match *self.get() {
642-
Some(hir::Public) => write!(f, "pub "),
643-
Some(hir::Inherited) | None => Ok(())
642+
Some(clean::Public) => write!(f, "pub "),
643+
Some(clean::Inherited) | None => Ok(())
644644
}
645645
}
646646
}

src/librustdoc/html/render.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,8 @@ impl Context {
14081408
match it.inner {
14091409
clean::StrippedItem(..) => true,
14101410
clean::ModuleItem(ref m) => {
1411-
it.doc_value().is_none() && m.items.is_empty() && it.visibility != Some(hir::Public)
1411+
it.doc_value().is_none() && m.items.is_empty()
1412+
&& it.visibility != Some(clean::Public)
14121413
},
14131414
_ => false,
14141415
}

src/librustdoc/passes.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc::util::nodemap::DefIdSet;
1414
use std::cmp;
1515
use std::string::String;
1616
use std::usize;
17-
use rustc::hir;
1817

1918
use clean::{self, Attributes, GetDefId};
2019
use clean::Item;
@@ -133,13 +132,13 @@ impl<'a> fold::DocFolder for Stripper<'a> {
133132
}
134133

135134
clean::StructFieldItem(..) => {
136-
if i.visibility != Some(hir::Public) {
135+
if i.visibility != Some(clean::Public) {
137136
return Strip(i).fold();
138137
}
139138
}
140139

141140
clean::ModuleItem(..) => {
142-
if i.def_id.is_local() && i.visibility != Some(hir::Public) {
141+
if i.def_id.is_local() && i.visibility != Some(clean::Public) {
143142
return Strip(self.fold_item_recur(i).unwrap()).fold()
144143
}
145144
}
@@ -226,7 +225,7 @@ impl fold::DocFolder for ImportStripper {
226225
fn fold_item(&mut self, i: Item) -> Option<Item> {
227226
match i.inner {
228227
clean::ExternCrateItem(..) |
229-
clean::ImportItem(..) if i.visibility != Some(hir::Public) => None,
228+
clean::ImportItem(..) if i.visibility != Some(clean::Public) => None,
230229
_ => self.fold_item_recur(i)
231230
}
232231
}

0 commit comments

Comments
 (0)