Skip to content

Commit b1d3d3a

Browse files
committed
make MarkdownItemInfo a field struct
1 parent 0d162b2 commit b1d3d3a

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/librustdoc/html/markdown.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ pub(crate) struct MarkdownWithToc<'a> {
111111
}
112112
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
113113
/// and includes no paragraph tags.
114-
pub(crate) struct MarkdownItemInfo<'a>(pub(crate) &'a str, pub(crate) &'a mut IdMap);
114+
pub(crate) struct MarkdownItemInfo<'a> {
115+
pub(crate) content: &'a str,
116+
pub(crate) ids: &'a mut IdMap,
117+
}
115118
/// A tuple struct like `Markdown` that renders only the first paragraph.
116119
pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);
117120

@@ -1459,15 +1462,19 @@ impl MarkdownWithToc<'_> {
14591462
}
14601463
}
14611464

1462-
impl MarkdownItemInfo<'_> {
1465+
impl<'a> MarkdownItemInfo<'a> {
1466+
pub(crate) fn new(content: &'a str, ids: &'a mut IdMap) -> Self {
1467+
Self { content, ids }
1468+
}
1469+
14631470
pub(crate) fn write_into(self, mut f: impl fmt::Write) -> fmt::Result {
1464-
let MarkdownItemInfo(md, ids) = self;
1471+
let MarkdownItemInfo { content, ids } = self;
14651472

14661473
// This is actually common enough to special-case
1467-
if md.is_empty() {
1474+
if content.is_empty() {
14681475
return Ok(());
14691476
}
1470-
let p = Parser::new_ext(md, main_body_opts()).into_offset_iter();
1477+
let p = Parser::new_ext(content, main_body_opts()).into_offset_iter();
14711478

14721479
// Treat inline HTML as plain text.
14731480
let p = p.map(|event| match event.0 {

src/librustdoc/html/markdown/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ fn test_markdown_html_escape() {
471471
fn t(input: &str, expect: &str) {
472472
let mut idmap = IdMap::new();
473473
let mut output = String::new();
474-
MarkdownItemInfo(input, &mut idmap).write_into(&mut output).unwrap();
474+
MarkdownItemInfo::new(input, &mut idmap).write_into(&mut output).unwrap();
475475
assert_eq!(output, expect, "original: {}", input);
476476
}
477477

src/librustdoc/html/render/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ fn short_item_info(
877877
if let Some(note) = note {
878878
let note = note.as_str();
879879
let mut id_map = cx.id_map.borrow_mut();
880-
let html = MarkdownItemInfo(note, &mut id_map);
880+
let html = MarkdownItemInfo::new(note, &mut id_map);
881881
message.push_str(": ");
882882
html.write_into(&mut message).unwrap();
883883
}

0 commit comments

Comments
 (0)