about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2025-05-26 09:10:04 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2025-05-26 09:10:04 +1000
commitfa8e910ed915a207f58531b3bb5f3236a5836c4d (patch)
treedaebd0481e8dccbc35b35c6f3b89ffcee6460701
parent581fd271f6adc97999a73f2f06abde7db70f4abb (diff)
downloadrust-fa8e910ed915a207f58531b3bb5f3236a5836c4d.tar.gz
rust-fa8e910ed915a207f58531b3bb5f3236a5836c4d.zip
Simplify `make_href`.
Currently it is passed an `fqp` slice which it calls `to_vec` on and
returns. This is a bit odd. It's better to let the call site clone if
necessary. (One call site does, one does not).
-rw-r--r--src/librustdoc/html/format.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 1650a56bffb..efd74d74f2c 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -483,7 +483,7 @@ fn generate_item_def_id_path(
     let mut is_remote = false;
 
     let url_parts = url_parts(cx.cache(), def_id, module_fqp, &cx.current, &mut is_remote)?;
-    let (url_parts, shortty, fqp) = make_href(root_path, shortty, url_parts, &fqp, is_remote)?;
+    let (url_parts, shortty) = make_href(root_path, shortty, url_parts, &fqp, is_remote)?;
     if def_id == original_def_id {
         return Ok((url_parts, shortty, fqp));
     }
@@ -521,7 +521,7 @@ fn make_href(
     mut url_parts: UrlPartsBuilder,
     fqp: &[Symbol],
     is_remote: bool,
-) -> Result<(String, ItemType, Vec<Symbol>), HrefError> {
+) -> Result<(String, ItemType), HrefError> {
     if !is_remote && let Some(root_path) = root_path {
         let root = root_path.trim_end_matches('/');
         url_parts.push_front(root);
@@ -536,7 +536,7 @@ fn make_href(
             url_parts.push_fmt(format_args!("{shortty}.{last}.html"));
         }
     }
-    Ok((url_parts.finish(), shortty, fqp.to_vec()))
+    Ok((url_parts.finish(), shortty))
 }
 
 pub(crate) fn href_with_root_path(
@@ -607,6 +607,7 @@ pub(crate) fn href_with_root_path(
         }
     };
     make_href(root_path, shortty, url_parts, fqp, is_remote)
+        .map(|(url_parts, short_ty)| (url_parts, short_ty, fqp.clone()))
 }
 
 pub(crate) fn href(