Skip to content

Commit 69a8869

Browse files
committed
---
yaml --- r: 273911 b: refs/heads/beta c: 0ef85c1 h: refs/heads/master i: 273909: cca4be8 273907: 123b94a 273903: e6dc220
1 parent da50ef6 commit 69a8869

File tree

5 files changed

+77
-57
lines changed

5 files changed

+77
-57
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: b1543a1aac0c9443e509e00ed6cddcc9b9400ac3
26+
refs/heads/beta: 0ef85c1e6a573d736592f00402456616a25eee0f
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustdoc/clean/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
pub use self::Type::*;
1515
pub use self::PrimitiveType::*;
1616
pub use self::TypeKind::*;
17-
pub use self::StructField::*;
1817
pub use self::VariantKind::*;
1918
pub use self::Mutability::*;
2019
pub use self::Import::*;
@@ -309,6 +308,15 @@ impl Item {
309308
pub fn is_stripped(&self) -> bool {
310309
match self.inner { StrippedItem(..) => true, _ => false }
311310
}
311+
pub fn has_stripped_fields(&self) -> Option<bool> {
312+
match self.inner {
313+
StructItem(ref _struct) => Some(_struct.fields_stripped),
314+
VariantItem(Variant { kind: StructVariant(ref vstruct)} ) => {
315+
Some(vstruct.fields_stripped)
316+
},
317+
_ => None,
318+
}
319+
}
312320

313321
pub fn stability_class(&self) -> String {
314322
self.stability.as_ref().map(|ref s| {
@@ -346,7 +354,7 @@ pub enum ItemEnum {
346354
TyMethodItem(TyMethod),
347355
/// A method with a body.
348356
MethodItem(Method),
349-
StructFieldItem(StructField),
357+
StructFieldItem(Type),
350358
VariantItem(Variant),
351359
/// `fn`s from an extern block
352360
ForeignFunctionItem(Function),
@@ -1740,12 +1748,6 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
17401748
}
17411749
}
17421750

1743-
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
1744-
pub enum StructField {
1745-
HiddenStructField, // inserted later by strip passes
1746-
TypedStructField(Type),
1747-
}
1748-
17491751
impl Clean<Item> for hir::StructField {
17501752
fn clean(&self, cx: &DocContext) -> Item {
17511753
Item {
@@ -1756,7 +1758,7 @@ impl Clean<Item> for hir::StructField {
17561758
stability: get_stability(cx, cx.map.local_def_id(self.id)),
17571759
deprecation: get_deprecation(cx, cx.map.local_def_id(self.id)),
17581760
def_id: cx.map.local_def_id(self.id),
1759-
inner: StructFieldItem(TypedStructField(self.ty.clean(cx))),
1761+
inner: StructFieldItem(self.ty.clean(cx)),
17601762
}
17611763
}
17621764
}
@@ -1773,7 +1775,7 @@ impl<'tcx> Clean<Item> for ty::FieldDefData<'tcx, 'static> {
17731775
stability: get_stability(cx, self.did),
17741776
deprecation: get_deprecation(cx, self.did),
17751777
def_id: self.did,
1776-
inner: StructFieldItem(TypedStructField(self.unsubst_ty().clean(cx))),
1778+
inner: StructFieldItem(self.unsubst_ty().clean(cx)),
17771779
}
17781780
}
17791781
}
@@ -1904,9 +1906,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
19041906
def_id: field.did,
19051907
stability: get_stability(cx, field.did),
19061908
deprecation: get_deprecation(cx, field.did),
1907-
inner: StructFieldItem(
1908-
TypedStructField(field.unsubst_ty().clean(cx))
1909-
)
1909+
inner: StructFieldItem(field.unsubst_ty().clean(cx))
19101910
}
19111911
}).collect()
19121912
})

branches/beta/src/librustdoc/html/render.rs

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,13 +1020,9 @@ impl DocFolder for Cache {
10201020
}
10211021
_ => ((None, Some(&*self.stack)), false)
10221022
};
1023-
let hidden_field = match item.inner {
1024-
clean::StructFieldItem(clean::HiddenStructField) => true,
1025-
_ => false
1026-
};
10271023

10281024
match parent {
1029-
(parent, Some(path)) if is_method || (!self.stripped_mod && !hidden_field) => {
1025+
(parent, Some(path)) if is_method || (!self.stripped_mod) => {
10301026
// Needed to determine `self` type.
10311027
let parent_basename = self.parent_stack.first().and_then(|parent| {
10321028
match self.paths.get(parent) {
@@ -1051,7 +1047,7 @@ impl DocFolder for Cache {
10511047
});
10521048
}
10531049
}
1054-
(Some(parent), None) if is_method || (!self.stripped_mod && !hidden_field)=> {
1050+
(Some(parent), None) if is_method || (!self.stripped_mod)=> {
10551051
if parent.is_local() {
10561052
// We have a parent, but we don't know where they're
10571053
// defined yet. Wait for later to index this item.
@@ -2165,8 +2161,7 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
21652161
document(w, cx, it)?;
21662162
let mut fields = s.fields.iter().filter(|f| {
21672163
match f.inner {
2168-
clean::StructFieldItem(clean::HiddenStructField) => false,
2169-
clean::StructFieldItem(clean::TypedStructField(..)) => true,
2164+
clean::StructFieldItem(..) => true,
21702165
_ => false,
21712166
}
21722167
}).peekable();
@@ -2256,7 +2251,7 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
22562251
if let clean::VariantItem( Variant { kind: StructVariant(ref s) } ) = variant.inner {
22572252
let fields = s.fields.iter().filter(|f| {
22582253
match f.inner {
2259-
clean::StructFieldItem(clean::TypedStructField(..)) => true,
2254+
clean::StructFieldItem(..) => true,
22602255
_ => false,
22612256
}
22622257
});
@@ -2315,24 +2310,17 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
23152310
match ty {
23162311
doctree::Plain => {
23172312
write!(w, " {{\n{}", tab)?;
2318-
let mut fields_stripped = false;
23192313
for field in fields {
2320-
match field.inner {
2321-
clean::StructFieldItem(clean::HiddenStructField) => {
2322-
fields_stripped = true;
2323-
}
2324-
clean::StructFieldItem(clean::TypedStructField(ref ty)) => {
2325-
write!(w, " {}{}: {},\n{}",
2326-
VisSpace(field.visibility),
2327-
field.name.as_ref().unwrap(),
2328-
*ty,
2329-
tab)?;
2330-
}
2331-
_ => unreachable!(),
2332-
};
2314+
if let clean::StructFieldItem(ref ty) = field.inner {
2315+
write!(w, " {}{}: {},\n{}",
2316+
VisSpace(field.visibility),
2317+
field.name.as_ref().unwrap(),
2318+
*ty,
2319+
tab)?;
2320+
}
23332321
}
23342322

2335-
if fields_stripped {
2323+
if it.has_stripped_fields().unwrap() {
23362324
write!(w, " // some fields omitted\n{}", tab)?;
23372325
}
23382326
write!(w, "}}")?;
@@ -2344,10 +2332,10 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
23442332
write!(w, ", ")?;
23452333
}
23462334
match field.inner {
2347-
clean::StructFieldItem(clean::HiddenStructField) => {
2335+
clean::StrippedItem(box clean::StructFieldItem(..)) => {
23482336
write!(w, "_")?
23492337
}
2350-
clean::StructFieldItem(clean::TypedStructField(ref ty)) => {
2338+
clean::StructFieldItem(ref ty) => {
23512339
write!(w, "{}{}", VisSpace(field.visibility), *ty)?
23522340
}
23532341
_ => unreachable!()

branches/beta/src/librustdoc/passes.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@ pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
4040

4141
// use a dedicated hidden item for given item type if any
4242
match i.inner {
43-
clean::StructFieldItem(..) => {
44-
return Some(clean::Item {
45-
inner: clean::StructFieldItem(clean::HiddenStructField),
46-
..i
47-
});
43+
clean::StructFieldItem(..) | clean::ModuleItem(..) => {
44+
return Strip(i).fold()
4845
}
49-
clean::ModuleItem(..) => return Strip(i).fold(),
5046
_ => return None,
5147
}
5248
}
@@ -130,26 +126,18 @@ impl<'a> fold::DocFolder for Stripper<'a> {
130126
clean::StructItem(..) | clean::EnumItem(..) |
131127
clean::TraitItem(..) | clean::FunctionItem(..) |
132128
clean::VariantItem(..) | clean::MethodItem(..) |
133-
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) => {
129+
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) |
130+
clean::ConstantItem(..) => {
134131
if i.def_id.is_local() {
135132
if !self.access_levels.is_exported(i.def_id) {
136133
return None;
137134
}
138135
}
139136
}
140137

141-
clean::ConstantItem(..) => {
142-
if i.def_id.is_local() && !self.access_levels.is_exported(i.def_id) {
143-
return None;
144-
}
145-
}
146-
147138
clean::StructFieldItem(..) => {
148139
if i.visibility != Some(hir::Public) {
149-
return Some(clean::Item {
150-
inner: clean::StructFieldItem(clean::HiddenStructField),
151-
..i
152-
})
140+
return Strip(i).fold();
153141
}
154142
}
155143

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// @has structfields/struct.Foo.html
12+
pub struct Foo {
13+
// @has - //pre "pub a: ()"
14+
pub a: (),
15+
// @has - //pre "// some fields omitted"
16+
// @!has - //pre "b: ()"
17+
b: (),
18+
// @!has - //pre "c: usize"
19+
#[doc(hidden)]
20+
c: usize,
21+
// @has - //pre "pub d: usize"
22+
pub d: usize,
23+
}
24+
25+
// @has structfields/struct.Bar.html
26+
pub struct Bar {
27+
// @has - //pre "pub a: ()"
28+
pub a: (),
29+
// @!has - //pre "// some fields omitted"
30+
}
31+
32+
// @has structfields/enum.Qux.html
33+
pub enum Qux {
34+
Quz {
35+
// @has - //pre "a: ()"
36+
a: (),
37+
// @!has - //pre "b: ()"
38+
#[doc(hidden)]
39+
b: (),
40+
// @has - //pre "c: usize"
41+
c: usize,
42+
// @has - //pre "// some fields omitted"
43+
},
44+
}

0 commit comments

Comments
 (0)