Skip to content

Commit 12357f6

Browse files
committed
---
yaml --- r: 272844 b: refs/heads/beta c: 0321562 h: refs/heads/master
1 parent 589e984 commit 12357f6

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
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: 2a28b69948e13ec09a8a7701fa4d9001e880ad5f
26+
refs/heads/beta: 032156210deaf71fddc4f8577fa2b541606ed547
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: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,8 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
175175
};
176176
let mut tmp = Vec::new();
177177
for child in &mut m.items {
178-
match child.inner {
179-
ModuleItem(..) => {}
180-
_ => continue,
178+
if !child.is_mod() {
179+
continue;
181180
}
182181
let prim = match PrimitiveType::find(&child.attrs) {
183182
Some(prim) => prim,
@@ -272,7 +271,12 @@ impl Item {
272271
pub fn doc_value<'a>(&'a self) -> Option<&'a str> {
273272
self.attrs.value("doc")
274273
}
275-
274+
pub fn is_crate(&self) -> bool {
275+
match self.inner {
276+
ModuleItem(Module { items: _, is_crate: true }) => true,
277+
_ => false
278+
}
279+
}
276280
pub fn is_mod(&self) -> bool {
277281
match self.inner { ModuleItem(..) => true, _ => false }
278282
}
@@ -288,6 +292,18 @@ impl Item {
288292
pub fn is_fn(&self) -> bool {
289293
match self.inner { FunctionItem(..) => true, _ => false }
290294
}
295+
pub fn is_associated_type(&self) -> bool {
296+
match self.inner { AssociatedTypeItem(..) => true, _ => false }
297+
}
298+
pub fn is_associated_const(&self) -> bool {
299+
match self.inner { AssociatedConstItem(..) => true, _ => false }
300+
}
301+
pub fn is_method(&self) -> bool {
302+
match self.inner { MethodItem(..) => true, _ => false }
303+
}
304+
pub fn is_ty_method(&self) -> bool {
305+
match self.inner { TyMethodItem(..) => true, _ => false }
306+
}
291307

292308
pub fn stability_class(&self) -> String {
293309
self.stability.as_ref().map(|ref s| {

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

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,11 +1266,7 @@ impl Context {
12661266
}
12671267
title.push_str(" - Rust");
12681268
let tyname = shortty(it).to_static_str();
1269-
let is_crate = match it.inner {
1270-
clean::ModuleItem(clean::Module { items: _, is_crate: true }) => true,
1271-
_ => false
1272-
};
1273-
let desc = if is_crate {
1269+
let desc = if it.is_crate() {
12741270
format!("API documentation for the Rust `{}` crate.",
12751271
cx.layout.krate)
12761272
} else {
@@ -1891,18 +1887,10 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
18911887
bounds,
18921888
WhereClause(&t.generics)));
18931889

1894-
let types = t.items.iter().filter(|m| {
1895-
match m.inner { clean::AssociatedTypeItem(..) => true, _ => false }
1896-
}).collect::<Vec<_>>();
1897-
let consts = t.items.iter().filter(|m| {
1898-
match m.inner { clean::AssociatedConstItem(..) => true, _ => false }
1899-
}).collect::<Vec<_>>();
1900-
let required = t.items.iter().filter(|m| {
1901-
match m.inner { clean::TyMethodItem(_) => true, _ => false }
1902-
}).collect::<Vec<_>>();
1903-
let provided = t.items.iter().filter(|m| {
1904-
match m.inner { clean::MethodItem(_) => true, _ => false }
1905-
}).collect::<Vec<_>>();
1890+
let types = t.items.iter().filter(|m| m.is_associated_type()).collect::<Vec<_>>();
1891+
let consts = t.items.iter().filter(|m| m.is_associated_const()).collect::<Vec<_>>();
1892+
let required = t.items.iter().filter(|m| m.is_ty_method()).collect::<Vec<_>>();
1893+
let provided = t.items.iter().filter(|m| m.is_method()).collect::<Vec<_>>();
19061894

19071895
if t.items.is_empty() {
19081896
try!(write!(w, "{{ }}"));
@@ -2600,7 +2588,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
26002588
try!(write!(fmt, "</p>"));
26012589

26022590
// sidebar refers to the enclosing module, not this module
2603-
let relpath = if shortty(it) == ItemType::Module { "../" } else { "" };
2591+
let relpath = if it.is_mod() { "../" } else { "" };
26042592
try!(write!(fmt,
26052593
"<script>window.sidebarCurrent = {{\
26062594
name: '{name}', \

0 commit comments

Comments
 (0)