Skip to content

Commit 61fccf0

Browse files
authored
Rollup merge of #74359 - lzutao:rustdoc-tostring, r=GuillaumeGomez
rustdoc: Rename internal API fns to `into_string` to avoid surprising listed in API guidelines.
2 parents 196243e + 0f4e4a0 commit 61fccf0

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

src/librustdoc/externalfiles.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ impl ExternalHtml {
3737
let bc = format!(
3838
"{}{}",
3939
bc,
40-
Markdown(&m_bc, &[], id_map, codes, edition, playground).to_string()
40+
Markdown(&m_bc, &[], id_map, codes, edition, playground).into_string()
4141
);
4242
let ac = load_external_files(after_content, diag)?;
4343
let m_ac = load_external_files(md_after_content, diag)?;
4444
let ac = format!(
4545
"{}{}",
4646
ac,
47-
Markdown(&m_ac, &[], id_map, codes, edition, playground).to_string()
47+
Markdown(&m_ac, &[], id_map, codes, edition, playground).into_string()
4848
);
4949
Some(ExternalHtml { in_header: ih, before_content: bc, after_content: ac })
5050
}

src/librustdoc/html/markdown.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! let s = "My *markdown* _text_";
1414
//! let mut id_map = IdMap::new();
1515
//! let md = Markdown(s, &[], &mut id_map, ErrorCodes::Yes, Edition::Edition2015, &None);
16-
//! let html = md.to_string();
16+
//! let html = md.into_string();
1717
//! // ... something using html
1818
//! ```
1919
@@ -848,7 +848,7 @@ impl LangString {
848848
}
849849

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

854854
// This is actually common enough to special-case
@@ -878,7 +878,7 @@ impl Markdown<'_> {
878878
}
879879

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

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

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

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

928928
impl MarkdownSummaryLine<'_> {
929-
pub fn to_string(self) -> String {
929+
pub fn into_string(self) -> String {
930930
let MarkdownSummaryLine(md, links) = self;
931931
// This is actually common enough to special-case
932932
if md.is_empty() {

src/librustdoc/html/markdown/tests.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn test_header() {
134134
fn t(input: &str, expect: &str) {
135135
let mut map = IdMap::new();
136136
let output =
137-
Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
137+
Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
138138
assert_eq!(output, expect, "original: {}", input);
139139
}
140140

@@ -166,7 +166,8 @@ fn test_header() {
166166
fn test_header_ids_multiple_blocks() {
167167
let mut map = IdMap::new();
168168
fn t(map: &mut IdMap, input: &str, expect: &str) {
169-
let output = Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
169+
let output =
170+
Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
170171
assert_eq!(output, expect, "original: {}", input);
171172
}
172173

@@ -228,7 +229,7 @@ fn test_markdown_html_escape() {
228229
fn t(input: &str, expect: &str) {
229230
let mut idmap = IdMap::new();
230231
let output =
231-
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
232+
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
232233
assert_eq!(output, expect, "original: {}", input);
233234
}
234235

src/librustdoc/html/render.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ fn render_markdown(
18951895
cx.shared.edition,
18961896
&cx.shared.playground
18971897
)
1898-
.to_string()
1898+
.into_string()
18991899
)
19001900
}
19011901

@@ -2185,7 +2185,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
21852185
</tr>",
21862186
name = *myitem.name.as_ref().unwrap(),
21872187
stab_tags = stability_tags(myitem),
2188-
docs = MarkdownSummaryLine(doc_value, &myitem.links()).to_string(),
2188+
docs = MarkdownSummaryLine(doc_value, &myitem.links()).into_string(),
21892189
class = myitem.type_(),
21902190
add = add,
21912191
stab = stab.unwrap_or_else(String::new),
@@ -2278,7 +2278,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
22782278
cx.shared.edition,
22792279
&cx.shared.playground,
22802280
);
2281-
message.push_str(&format!(": {}", html.to_string()));
2281+
message.push_str(&format!(": {}", html.into_string()));
22822282
}
22832283
stability.push(format!(
22842284
"<div class='stab deprecated'><span class='emoji'>👎</span> {}</div>",
@@ -2332,7 +2332,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
23322332
cx.shared.edition,
23332333
&cx.shared.playground,
23342334
)
2335-
.to_string()
2335+
.into_string()
23362336
);
23372337
}
23382338

@@ -3632,7 +3632,7 @@ fn render_impl(
36323632
cx.shared.edition,
36333633
&cx.shared.playground
36343634
)
3635-
.to_string()
3635+
.into_string()
36363636
);
36373637
}
36383638
}

src/librustdoc/markdown.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ pub fn render<P: AsRef<Path>>(
6868
let mut ids = IdMap::new();
6969
let error_codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());
7070
let text = if !options.markdown_no_toc {
71-
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).to_string()
71+
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).into_string()
7272
} else {
73-
Markdown(text, &[], &mut ids, error_codes, edition, &playground).to_string()
73+
Markdown(text, &[], &mut ids, error_codes, edition, &playground).into_string()
7474
};
7575

7676
let err = write!(

src/tools/error_index_generator/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl Formatter for HTMLFormatter {
127127
DEFAULT_EDITION,
128128
&Some(playground)
129129
)
130-
.to_string()
130+
.into_string()
131131
)?
132132
}
133133
None => write!(output, "<p>No description.</p>\n")?,

0 commit comments

Comments
 (0)