Skip to content

Commit

Permalink
Rollup merge of rust-lang#74359 - lzutao:rustdoc-tostring, r=Guillaum…
Browse files Browse the repository at this point in the history
…eGomez

rustdoc: Rename internal API fns to `into_string`

to avoid surprising listed in API guidelines.
  • Loading branch information
Manishearth committed Jul 16, 2020
2 parents 6acbb12 + 0f4e4a0 commit c3eb4bc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/externalfiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ impl ExternalHtml {
let bc = format!(
"{}{}",
bc,
Markdown(&m_bc, &[], id_map, codes, edition, playground).to_string()
Markdown(&m_bc, &[], id_map, codes, edition, playground).into_string()
);
let ac = load_external_files(after_content, diag)?;
let m_ac = load_external_files(md_after_content, diag)?;
let ac = format!(
"{}{}",
ac,
Markdown(&m_ac, &[], id_map, codes, edition, playground).to_string()
Markdown(&m_ac, &[], id_map, codes, edition, playground).into_string()
);
Some(ExternalHtml { in_header: ih, before_content: bc, after_content: ac })
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! let s = "My *markdown* _text_";
//! let mut id_map = IdMap::new();
//! let md = Markdown(s, &[], &mut id_map, ErrorCodes::Yes, Edition::Edition2015, &None);
//! let html = md.to_string();
//! let html = md.into_string();
//! // ... something using html
//! ```

Expand Down Expand Up @@ -848,7 +848,7 @@ impl LangString {
}

impl Markdown<'_> {
pub fn to_string(self) -> String {
pub fn into_string(self) -> String {
let Markdown(md, links, mut ids, codes, edition, playground) = self;

// This is actually common enough to special-case
Expand Down Expand Up @@ -878,7 +878,7 @@ impl Markdown<'_> {
}

impl MarkdownWithToc<'_> {
pub fn to_string(self) -> String {
pub fn into_string(self) -> String {
let MarkdownWithToc(md, mut ids, codes, edition, playground) = self;

let p = Parser::new_ext(md, opts());
Expand All @@ -899,7 +899,7 @@ impl MarkdownWithToc<'_> {
}

impl MarkdownHtml<'_> {
pub fn to_string(self) -> String {
pub fn into_string(self) -> String {
let MarkdownHtml(md, mut ids, codes, edition, playground) = self;

// This is actually common enough to special-case
Expand All @@ -926,7 +926,7 @@ impl MarkdownHtml<'_> {
}

impl MarkdownSummaryLine<'_> {
pub fn to_string(self) -> String {
pub fn into_string(self) -> String {
let MarkdownSummaryLine(md, links) = self;
// This is actually common enough to special-case
if md.is_empty() {
Expand Down
7 changes: 4 additions & 3 deletions src/librustdoc/html/markdown/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn test_header() {
fn t(input: &str, expect: &str) {
let mut map = IdMap::new();
let output =
Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
assert_eq!(output, expect, "original: {}", input);
}

Expand Down Expand Up @@ -166,7 +166,8 @@ fn test_header() {
fn test_header_ids_multiple_blocks() {
let mut map = IdMap::new();
fn t(map: &mut IdMap, input: &str, expect: &str) {
let output = Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
let output =
Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
assert_eq!(output, expect, "original: {}", input);
}

Expand Down Expand Up @@ -228,7 +229,7 @@ fn test_markdown_html_escape() {
fn t(input: &str, expect: &str) {
let mut idmap = IdMap::new();
let output =
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
assert_eq!(output, expect, "original: {}", input);
}

Expand Down
10 changes: 5 additions & 5 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@ fn render_markdown(
cx.shared.edition,
&cx.shared.playground
)
.to_string()
.into_string()
)
}

Expand Down Expand Up @@ -2185,7 +2185,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
</tr>",
name = *myitem.name.as_ref().unwrap(),
stab_tags = stability_tags(myitem),
docs = MarkdownSummaryLine(doc_value, &myitem.links()).to_string(),
docs = MarkdownSummaryLine(doc_value, &myitem.links()).into_string(),
class = myitem.type_(),
add = add,
stab = stab.unwrap_or_else(String::new),
Expand Down Expand Up @@ -2281,7 +2281,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
cx.shared.edition,
&cx.shared.playground,
);
message.push_str(&format!(": {}", html.to_string()));
message.push_str(&format!(": {}", html.into_string()));
}
stability.push(format!(
"<div class='stab deprecated'><span class='emoji'>👎</span> {}</div>",
Expand Down Expand Up @@ -2322,7 +2322,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
cx.shared.edition,
&cx.shared.playground,
)
.to_string()
.into_string()
);
}

Expand Down Expand Up @@ -3621,7 +3621,7 @@ fn render_impl(
cx.shared.edition,
&cx.shared.playground
)
.to_string()
.into_string()
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ pub fn render<P: AsRef<Path>>(
let mut ids = IdMap::new();
let error_codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());
let text = if !options.markdown_no_toc {
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).to_string()
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).into_string()
} else {
Markdown(text, &[], &mut ids, error_codes, edition, &playground).to_string()
Markdown(text, &[], &mut ids, error_codes, edition, &playground).into_string()
};

let err = write!(
Expand Down
2 changes: 1 addition & 1 deletion src/tools/error_index_generator/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl Formatter for HTMLFormatter {
DEFAULT_EDITION,
&Some(playground)
)
.to_string()
.into_string()
)?
}
None => write!(output, "<p>No description.</p>\n")?,
Expand Down

0 comments on commit c3eb4bc

Please sign in to comment.