From 1e02a2b10bccb95cd0962ac79f75f63e8599aa8e Mon Sep 17 00:00:00 2001 From: thebabalola Date: Mon, 13 Apr 2026 23:07:39 +0100 Subject: [PATCH] Add test for list item leading whitespace trimming --- .../rustc_errors/src/markdown/tests/parse.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/compiler/rustc_errors/src/markdown/tests/parse.rs b/compiler/rustc_errors/src/markdown/tests/parse.rs index 807fda321179..1a8d19a1136e 100644 --- a/compiler/rustc_errors/src/markdown/tests/parse.rs +++ b/compiler/rustc_errors/src/markdown/tests/parse.rs @@ -377,3 +377,24 @@ fn test_codeblock_trailing_whitespace() { assert_eq!(t, MdTree::CodeBlock { txt: "code\n```abc\nrest", lang: Some("rust") }); assert_eq!(r, b""); } + +#[test] +fn test_list_item_leading_whitespace() { + // extra spaces after marker + let buf = "- hello"; + let (t, r) = parse_unordered_li(buf.as_bytes()); + assert_eq!(t, MdTree::UnorderedListItem(vec![MdTree::PlainText("hello")].into())); + assert_eq!(r, b""); + + // tab after the marker space + let buf = "- \thello"; + let (t, r) = parse_unordered_li(buf.as_bytes()); + assert_eq!(t, MdTree::UnorderedListItem(vec![MdTree::PlainText("hello")].into())); + assert_eq!(r, b""); + + // ordered list + let buf = "1. hello"; + let (t, r) = parse_ordered_li(buf.as_bytes()); + assert_eq!(t, MdTree::OrderedListItem(1, vec![MdTree::PlainText("hello")].into())); + assert_eq!(r, b""); +}