Skip to content

Commit fdfdb08

Browse files
committed
Replace custom trim_ascii_start with the standard library method
The local trim_ascii_start function in the markdown parser duplicates <[u8]>::trim_ascii_start() from the standard library (stable since 1.80). Remove the custom function and call the stdlib method directly. No behaviour change. Fixes rustfoundation/interop-initiative#53
1 parent 1e02a2b commit fdfdb08

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

  • compiler/rustc_errors/src/markdown

compiler/rustc_errors/src/markdown/parse.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> {
252252
fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> {
253253
let (txt, rest) = get_indented_section(&buf[2..]);
254254
let ctx = Context { .. };
255-
let stream = parse_recursive(trim_ascii_start(txt), ctx);
255+
let stream = parse_recursive(txt.trim_ascii_start(), ctx);
256256
(MdTree::UnorderedListItem(stream), rest)
257257
}
258258

@@ -261,7 +261,7 @@ fn parse_ordered_li(buf: &[u8]) -> Parsed<'_> {
261261
let (num, pos) = ord_list_start(buf).unwrap(); // success tested in caller
262262
let (txt, rest) = get_indented_section(&buf[pos..]);
263263
let ctx = Context { .. };
264-
let stream = parse_recursive(trim_ascii_start(txt), ctx);
264+
let stream = parse_recursive(txt.trim_ascii_start(), ctx);
265265
(MdTree::OrderedListItem(num, stream), rest)
266266
}
267267

@@ -578,12 +578,6 @@ fn trim_extra_ws(mut txt: &str) -> &str {
578578
&txt[..txt.len() - end_ws]
579579
}
580580

581-
/// If there is more than one whitespace char at start, trim the extras
582-
fn trim_ascii_start(buf: &[u8]) -> &[u8] {
583-
let count = buf.iter().take_while(|ch| ch.is_ascii_whitespace()).count();
584-
&buf[count..]
585-
}
586-
587581
#[cfg(test)]
588582
#[path = "tests/parse.rs"]
589583
mod tests;

0 commit comments

Comments
 (0)