diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-11-24 14:05:12 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-11-27 13:12:27 +0100 |
| commit | 4993807dd9416ed65b9cac0e507af34bfe04a4ad (patch) | |
| tree | a3c512ca70cc631130adf5d752e871e24a62aed9 | |
| parent | b5f265eeed23ac87ec6b4a7e6bc7cb4ea3e67c31 (diff) | |
| download | rust-4993807dd9416ed65b9cac0e507af34bfe04a4ad.tar.gz rust-4993807dd9416ed65b9cac0e507af34bfe04a4ad.zip | |
little intra-doc code cleanup
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 783168d7bd6..636f6bcb13b 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -121,23 +121,18 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { // Try looking for methods and associated items. let mut split = path_str.rsplitn(2, "::"); - let item_name = if let Some(first) = split.next() { - Symbol::intern(first) - } else { - return Err(ErrorKind::ResolutionFailure) - }; - - let mut path = if let Some(second) = split.next() { - second.to_owned() - } else { - return Err(ErrorKind::ResolutionFailure) - }; - - if path == "self" || path == "Self" { - if let Some(name) = current_item.as_ref() { - path = name.clone(); + let item_name = split.next() + .map(|f| Symbol::intern(f)) + .ok_or(ErrorKind::ResolutionFailure)?; + let path = split.next().map(|f| { + if f == "self" || f == "Self" { + if let Some(name) = current_item.as_ref() { + return name.clone(); + } } - } + f.to_owned() + }).ok_or(ErrorKind::ResolutionFailure)?; + if let Some(prim) = is_primitive(&path, TypeNS) { let did = primitive_impl(cx, &path).ok_or(ErrorKind::ResolutionFailure)?; return cx.tcx.associated_items(did) |
