From fdfdb0837c77d564f072d6efa1cfea6a46261d08 Mon Sep 17 00:00:00 2001 From: thebabalola Date: Mon, 13 Apr 2026 23:07:39 +0100 Subject: [PATCH] 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 https://github.com/rustfoundation/interop-initiative/issues/53 --- compiler/rustc_errors/src/markdown/parse.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_errors/src/markdown/parse.rs b/compiler/rustc_errors/src/markdown/parse.rs index 6512d9ce1997..cd39f9b34d43 100644 --- a/compiler/rustc_errors/src/markdown/parse.rs +++ b/compiler/rustc_errors/src/markdown/parse.rs @@ -252,7 +252,7 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> { fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> { let (txt, rest) = get_indented_section(&buf[2..]); let ctx = Context { .. }; - let stream = parse_recursive(trim_ascii_start(txt), ctx); + let stream = parse_recursive(txt.trim_ascii_start(), ctx); (MdTree::UnorderedListItem(stream), rest) } @@ -261,7 +261,7 @@ fn parse_ordered_li(buf: &[u8]) -> Parsed<'_> { let (num, pos) = ord_list_start(buf).unwrap(); // success tested in caller let (txt, rest) = get_indented_section(&buf[pos..]); let ctx = Context { .. }; - let stream = parse_recursive(trim_ascii_start(txt), ctx); + let stream = parse_recursive(txt.trim_ascii_start(), ctx); (MdTree::OrderedListItem(num, stream), rest) } @@ -578,12 +578,6 @@ fn trim_extra_ws(mut txt: &str) -> &str { &txt[..txt.len() - end_ws] } -/// If there is more than one whitespace char at start, trim the extras -fn trim_ascii_start(buf: &[u8]) -> &[u8] { - let count = buf.iter().take_while(|ch| ch.is_ascii_whitespace()).count(); - &buf[count..] -} - #[cfg(test)] #[path = "tests/parse.rs"] mod tests;