Skip to content

Commit 2b70da1

Browse files
bugadaniJoshua Nelson
and
Joshua Nelson
committed
Remove unnecessary scope
Co-authored-by: Joshua Nelson <[email protected]>
1 parent 08f7b0a commit 2b70da1

File tree

1 file changed

+33
-36
lines changed

1 file changed

+33
-36
lines changed

src/librustdoc/html/markdown.rs

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,43 +1135,40 @@ crate fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
11351135
let mut links = vec![];
11361136
let mut shortcut_links = vec![];
11371137

1138-
{
1139-
let locate = |s: &str| unsafe {
1140-
let s_start = s.as_ptr();
1141-
let s_end = s_start.add(s.len());
1142-
let md_start = md.as_ptr();
1143-
let md_end = md_start.add(md.len());
1144-
if md_start <= s_start && s_end <= md_end {
1145-
let start = s_start.offset_from(md_start) as usize;
1146-
let end = s_end.offset_from(md_start) as usize;
1147-
Some(start..end)
1148-
} else {
1149-
None
1150-
}
1151-
};
1152-
1153-
let mut push = |link: BrokenLink<'_>| {
1154-
// FIXME: use `link.span` instead of `locate`
1155-
// (doing it now includes the `[]` as well as the text)
1156-
shortcut_links.push((link.reference.to_owned(), locate(link.reference)));
1138+
let locate = |s: &str| unsafe {
1139+
let s_start = s.as_ptr();
1140+
let s_end = s_start.add(s.len());
1141+
let md_start = md.as_ptr();
1142+
let md_end = md_start.add(md.len());
1143+
if md_start <= s_start && s_end <= md_end {
1144+
let start = s_start.offset_from(md_start) as usize;
1145+
let end = s_end.offset_from(md_start) as usize;
1146+
Some(start..end)
1147+
} else {
11571148
None
1158-
};
1159-
let p =
1160-
Parser::new_with_broken_link_callback(md, opts(), Some(&mut push)).into_offset_iter();
1161-
1162-
// There's no need to thread an IdMap through to here because
1163-
// the IDs generated aren't going to be emitted anywhere.
1164-
let mut ids = IdMap::new();
1165-
let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids));
1166-
1167-
for ev in iter {
1168-
if let Event::Start(Tag::Link(_, dest, _)) = ev.0 {
1169-
debug!("found link: {}", dest);
1170-
links.push(match dest {
1171-
CowStr::Borrowed(s) => (s.to_owned(), locate(s)),
1172-
s @ (CowStr::Boxed(..) | CowStr::Inlined(..)) => (s.into_string(), None),
1173-
});
1174-
}
1149+
}
1150+
};
1151+
1152+
let mut push = |link: BrokenLink<'_>| {
1153+
// FIXME: use `link.span` instead of `locate`
1154+
// (doing it now includes the `[]` as well as the text)
1155+
shortcut_links.push((link.reference.to_owned(), locate(link.reference)));
1156+
None
1157+
};
1158+
let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut push)).into_offset_iter();
1159+
1160+
// There's no need to thread an IdMap through to here because
1161+
// the IDs generated aren't going to be emitted anywhere.
1162+
let mut ids = IdMap::new();
1163+
let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids));
1164+
1165+
for ev in iter {
1166+
if let Event::Start(Tag::Link(_, dest, _)) = ev.0 {
1167+
debug!("found link: {}", dest);
1168+
links.push(match dest {
1169+
CowStr::Borrowed(s) => (s.to_owned(), locate(s)),
1170+
s @ (CowStr::Boxed(..) | CowStr::Inlined(..)) => (s.into_string(), None),
1171+
});
11751172
}
11761173
}
11771174

0 commit comments

Comments
 (0)