Skip to content

Commit 6a36b3f

Browse files
Apply review comments and improve code
1 parent 19630ea commit 6a36b3f

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

src/librustdoc/clean/types.rs

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,34 +1410,30 @@ impl Type {
14101410

14111411
impl Type {
14121412
fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> {
1413-
fn inner<T: GetDefId>(t: &T, cache: Option<&Cache>) -> Option<DefId> {
1414-
match cache {
1415-
Some(c) => t.def_id_full(c),
1416-
None => t.def_id(),
1417-
}
1418-
}
1419-
1420-
match *self {
1421-
ResolvedPath { did, .. } => Some(did),
1422-
Primitive(p) => cache.and_then(|c| c.primitive_locations.get(&p).cloned()),
1423-
BorrowedRef { type_: box Generic(..), .. } => {
1424-
inner(&Primitive(PrimitiveType::Reference), cache)
1425-
}
1426-
BorrowedRef { ref type_, .. } => inner(&**type_, cache),
1413+
let t: &dyn GetDefId = match *self {
1414+
ResolvedPath { did, .. } => return Some(did),
1415+
Primitive(p) => return cache.and_then(|c| c.primitive_locations.get(&p).cloned()),
1416+
BorrowedRef { type_: box Generic(..), .. } => &Primitive(PrimitiveType::Reference),
1417+
BorrowedRef { ref type_, .. } => return type_.inner_def_id(cache),
14271418
Tuple(ref tys) => {
14281419
if tys.is_empty() {
1429-
inner(&Primitive(PrimitiveType::Unit), cache)
1420+
&Primitive(PrimitiveType::Unit)
14301421
} else {
1431-
inner(&Primitive(PrimitiveType::Tuple), cache)
1422+
&Primitive(PrimitiveType::Tuple)
14321423
}
14331424
}
1434-
BareFunction(..) => inner(&Primitive(PrimitiveType::Fn), cache),
1435-
Never => inner(&Primitive(PrimitiveType::Never), cache),
1436-
Slice(..) => inner(&Primitive(PrimitiveType::Slice), cache),
1437-
Array(..) => inner(&Primitive(PrimitiveType::Array), cache),
1438-
RawPointer(..) => inner(&Primitive(PrimitiveType::RawPointer), cache),
1439-
QPath { ref self_type, .. } => inner(&**self_type, cache),
1440-
_ => None,
1425+
BareFunction(..) => &Primitive(PrimitiveType::Fn),
1426+
Never => &Primitive(PrimitiveType::Never),
1427+
Slice(..) => &Primitive(PrimitiveType::Slice),
1428+
Array(..) => &Primitive(PrimitiveType::Array),
1429+
RawPointer(..) => &Primitive(PrimitiveType::RawPointer),
1430+
QPath { ref self_type, .. } => return self_type.inner_def_id(cache),
1431+
// FIXME: remove this wildcard
1432+
_ => return None,
1433+
};
1434+
match cache {
1435+
Some(c) => t.def_id_full(c),
1436+
None => t.def_id(),
14411437
}
14421438
}
14431439
}

src/librustdoc/html/render/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
7878
desc: item.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s)),
7979
parent: Some(did),
8080
parent_idx: None,
81-
search_type: get_index_search_type(&item, Some(cache)),
81+
search_type: get_index_search_type(&item, None),
8282
});
8383
for alias in item.attrs.get_doc_aliases() {
8484
cache

0 commit comments

Comments
 (0)