about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDániel Buga <bugadani@gmail.com>2020-12-31 10:07:57 +0100
committerDániel Buga <bugadani@gmail.com>2020-12-31 10:41:15 +0100
commit2b70da1661995dc3817e07f5230d192b658db0d5 (patch)
treec6c4c06a42621d12c7c5d5482cdc6b5642c7c15c
parent08f7b0a422587dbf192a85ce04fcbec07f8023de (diff)
downloadrust-2b70da1661995dc3817e07f5230d192b658db0d5.tar.gz
rust-2b70da1661995dc3817e07f5230d192b658db0d5.zip
Remove unnecessary scope
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
-rw-r--r--src/librustdoc/html/markdown.rs69
1 files changed, 33 insertions, 36 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 7a922f570da..cabe4b49e98 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -1135,43 +1135,40 @@ crate fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
     let mut links = vec![];
     let mut shortcut_links = vec![];
 
-    {
-        let locate = |s: &str| unsafe {
-            let s_start = s.as_ptr();
-            let s_end = s_start.add(s.len());
-            let md_start = md.as_ptr();
-            let md_end = md_start.add(md.len());
-            if md_start <= s_start && s_end <= md_end {
-                let start = s_start.offset_from(md_start) as usize;
-                let end = s_end.offset_from(md_start) as usize;
-                Some(start..end)
-            } else {
-                None
-            }
-        };
-
-        let mut push = |link: BrokenLink<'_>| {
-            // FIXME: use `link.span` instead of `locate`
-            // (doing it now includes the `[]` as well as the text)
-            shortcut_links.push((link.reference.to_owned(), locate(link.reference)));
+    let locate = |s: &str| unsafe {
+        let s_start = s.as_ptr();
+        let s_end = s_start.add(s.len());
+        let md_start = md.as_ptr();
+        let md_end = md_start.add(md.len());
+        if md_start <= s_start && s_end <= md_end {
+            let start = s_start.offset_from(md_start) as usize;
+            let end = s_end.offset_from(md_start) as usize;
+            Some(start..end)
+        } else {
             None
-        };
-        let p =
-            Parser::new_with_broken_link_callback(md, opts(), Some(&mut push)).into_offset_iter();
-
-        // There's no need to thread an IdMap through to here because
-        // the IDs generated aren't going to be emitted anywhere.
-        let mut ids = IdMap::new();
-        let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids));
-
-        for ev in iter {
-            if let Event::Start(Tag::Link(_, dest, _)) = ev.0 {
-                debug!("found link: {}", dest);
-                links.push(match dest {
-                    CowStr::Borrowed(s) => (s.to_owned(), locate(s)),
-                    s @ (CowStr::Boxed(..) | CowStr::Inlined(..)) => (s.into_string(), None),
-                });
-            }
+        }
+    };
+
+    let mut push = |link: BrokenLink<'_>| {
+        // FIXME: use `link.span` instead of `locate`
+        // (doing it now includes the `[]` as well as the text)
+        shortcut_links.push((link.reference.to_owned(), locate(link.reference)));
+        None
+    };
+    let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut push)).into_offset_iter();
+
+    // There's no need to thread an IdMap through to here because
+    // the IDs generated aren't going to be emitted anywhere.
+    let mut ids = IdMap::new();
+    let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids));
+
+    for ev in iter {
+        if let Event::Start(Tag::Link(_, dest, _)) = ev.0 {
+            debug!("found link: {}", dest);
+            links.push(match dest {
+                CowStr::Borrowed(s) => (s.to_owned(), locate(s)),
+                s @ (CowStr::Boxed(..) | CowStr::Inlined(..)) => (s.into_string(), None),
+            });
         }
     }