about summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-12-25 22:22:23 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2024-12-25 22:22:23 +0100
commitbdc8df4cb5f370d23748ba92406a0ed1f0dbea63 (patch)
tree2f79618e4e50988a869f340c3bfd59d1eb601a75 /src/librustdoc/html
parent7c002ff9a70cb84fd1a91bc7b4a0f988cfc36fca (diff)
downloadrust-bdc8df4cb5f370d23748ba92406a0ed1f0dbea63.tar.gz
rust-bdc8df4cb5f370d23748ba92406a0ed1f0dbea63.zip
Improve rustdoc code
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/escape.rs7
-rw-r--r--src/librustdoc/html/markdown.rs6
-rw-r--r--src/librustdoc/html/render/context.rs2
-rw-r--r--src/librustdoc/html/render/mod.rs2
-rw-r--r--src/librustdoc/html/render/print_item.rs2
5 files changed, 9 insertions, 10 deletions
diff --git a/src/librustdoc/html/escape.rs b/src/librustdoc/html/escape.rs
index 48771571f8f..88654ed32da 100644
--- a/src/librustdoc/html/escape.rs
+++ b/src/librustdoc/html/escape.rs
@@ -104,10 +104,9 @@ impl fmt::Display for EscapeBodyTextWithWbr<'_> {
                 continue;
             }
             let is_uppercase = || s.chars().any(|c| c.is_uppercase());
-            let next_is_uppercase =
-                || pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase()));
-            let next_is_underscore = || pk.map_or(true, |(_, t)| t.contains('_'));
-            let next_is_colon = || pk.map_or(true, |(_, t)| t.contains(':'));
+            let next_is_uppercase = || pk.is_none_or(|(_, t)| t.chars().any(|c| c.is_uppercase()));
+            let next_is_underscore = || pk.is_none_or(|(_, t)| t.contains('_'));
+            let next_is_colon = || pk.is_none_or(|(_, t)| t.contains(':'));
             // Check for CamelCase.
             //
             // `i - last > 3` avoids turning FmRadio into Fm<wbr>Radio, which is technically
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index aa8fdaaee4c..7e835585b73 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -480,7 +480,7 @@ impl<'a, I: Iterator<Item = SpannedEvent<'a>>> Iterator for SpannedLinkReplacer<
     type Item = SpannedEvent<'a>;
 
     fn next(&mut self) -> Option<Self::Item> {
-        let Some((mut event, range)) = self.iter.next() else { return None };
+        let (mut event, range) = self.iter.next()?;
         self.inner.handle_event(&mut event);
         // Yield the modified event
         Some((event, range))
@@ -2039,7 +2039,7 @@ impl IdMap {
                 let candidate = candidate.to_string();
                 if is_default_id(&candidate) {
                     let id = format!("{}-{}", candidate, 1);
-                    self.map.insert(candidate.into(), 2);
+                    self.map.insert(candidate, 2);
                     id
                 } else {
                     candidate
@@ -2052,7 +2052,7 @@ impl IdMap {
             }
         };
 
-        self.map.insert(id.clone().into(), 1);
+        self.map.insert(id.clone(), 1);
         id
     }
 
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 2d5df75e7dc..5d96dbc0ee6 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -748,7 +748,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
                 &shared.layout,
                 &page,
                 "",
-                scrape_examples_help(&shared),
+                scrape_examples_help(shared),
                 &shared.style_files,
             );
             shared.fs.write(scrape_examples_help_file, v)?;
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index dfdf2cd6ec3..9a9ce31caaa 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -1974,7 +1974,7 @@ fn render_impl(
             .opt_doc_value()
             .map(|dox| {
                 Markdown {
-                    content: &*dox,
+                    content: &dox,
                     links: &i.impl_item.links(cx),
                     ids: &mut cx.id_map.borrow_mut(),
                     error_codes: cx.shared.codes,
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 0fb77d38f16..e8230e63c0f 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -1420,7 +1420,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
             ty: &'a clean::Type,
         ) -> impl fmt::Display + Captures<'a> + 'b + Captures<'cx> {
             display_fn(move |f| {
-                let v = ty.print(&self.cx);
+                let v = ty.print(self.cx);
                 write!(f, "{v}")
             })
         }