Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 15, 2020
1 parent fd4a88f commit 81a5b94
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 49 deletions.
8 changes: 3 additions & 5 deletions src/librustdoc/clean/inline.rs
Expand Up @@ -284,11 +284,9 @@ fn build_type_alias_type(cx: &DocContext<'_>, did: DefId) -> Option<clean::Type>

pub fn build_ty(cx: &DocContext, did: DefId) -> Option<clean::Type> {
match cx.tcx.def_kind(did)? {
DefKind::Struct |
DefKind::Union |
DefKind::Enum |
DefKind::Const |
DefKind::Static => Some(cx.tcx.type_of(did).clean(cx)),
DefKind::Struct | DefKind::Union | DefKind::Enum | DefKind::Const | DefKind::Static => {
Some(cx.tcx.type_of(did).clean(cx))
}
DefKind::TyAlias => build_type_alias_type(cx, did),
_ => None,
}
Expand Down
18 changes: 2 additions & 16 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -1124,14 +1124,7 @@ impl Clean<Item> for hir::ImplItem<'_> {
hir::ImplItemKind::TyAlias(ref ty) => {
let type_ = ty.clean(cx);
let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did));
TypedefItem(
Typedef {
type_,
generics: Generics::default(),
item_type,
},
true,
)
TypedefItem(Typedef { type_, generics: Generics::default(), item_type }, true)
}
hir::ImplItemKind::OpaqueTy(ref bounds) => OpaqueTyItem(
OpaqueTy { bounds: bounds.clean(cx), generics: Generics::default() },
Expand Down Expand Up @@ -2011,14 +2004,7 @@ impl Clean<Item> for doctree::Typedef<'_> {
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: TypedefItem(
Typedef {
type_,
generics: self.gen.clean(cx),
item_type,
},
false,
),
inner: TypedefItem(Typedef { type_, generics: self.gen.clean(cx), item_type }, false),
}
}
}
Expand Down
20 changes: 8 additions & 12 deletions src/librustdoc/html/render.rs
Expand Up @@ -3474,12 +3474,10 @@ fn render_deref_methods(
.items
.iter()
.filter_map(|item| match item.inner {
clean::TypedefItem(ref t, true) => {
Some(match *t {
clean::Typedef { item_type: Some(ref type_), .. } => (&t.type_, type_),
_ => (&t.type_, &t.type_),
})
}
clean::TypedefItem(ref t, true) => Some(match *t {
clean::Typedef { item_type: Some(ref type_), .. } => (&t.type_, type_),
_ => (&t.type_, &t.type_),
}),
_ => None,
})
.next()
Expand Down Expand Up @@ -4133,12 +4131,10 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
.items
.iter()
.filter_map(|item| match item.inner {
clean::TypedefItem(ref t, true) => {
Some(match *t {
clean::Typedef { item_type: Some(ref type_), .. } => (&t.type_, type_),
_ => (&t.type_, &t.type_),
})
}
clean::TypedefItem(ref t, true) => Some(match *t {
clean::Typedef { item_type: Some(ref type_), .. } => (&t.type_, type_),
_ => (&t.type_, &t.type_),
}),
_ => None,
})
.next()
Expand Down
31 changes: 15 additions & 16 deletions src/librustdoc/html/render/cache.rs
Expand Up @@ -574,7 +574,8 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
// has since been learned.
for &(did, ref item) in orphan_impl_items {
if let Some(&(ref fqp, _)) = paths.get(&did) {
if item.name.is_none() { // this is most likely from a typedef
if item.name.is_none() {
// this is most likely from a typedef
continue;
}
search_index.push(IndexItem {
Expand All @@ -596,22 +597,20 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {

for item in search_index {
item.parent_idx = match item.parent {
Some(nodeid) => {
Some(if nodeid_to_pathid.contains_key(&nodeid) {
*nodeid_to_pathid.get(&nodeid).expect("no pathid")
} else {
let pathid = lastpathid;
nodeid_to_pathid.insert(nodeid, pathid);
lastpathid += 1;
Some(nodeid) => Some(if nodeid_to_pathid.contains_key(&nodeid) {
*nodeid_to_pathid.get(&nodeid).expect("no pathid")
} else {
let pathid = lastpathid;
nodeid_to_pathid.insert(nodeid, pathid);
lastpathid += 1;

if let Some(&(ref fqp, short)) = paths.get(&nodeid) {
crate_paths.push((short, fqp.last().expect("no fqp").clone()));
} else {
continue
}
pathid
})
}
if let Some(&(ref fqp, short)) = paths.get(&nodeid) {
crate_paths.push((short, fqp.last().expect("no fqp").clone()));
} else {
continue;
}
pathid
}),
None => None,
};

Expand Down

0 comments on commit 81a5b94

Please sign in to comment.