diff options
| author | Ralf Jung <post@ralfj.de> | 2025-03-11 07:07:31 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-11 07:07:31 +0000 |
| commit | fe5235ee0f90f41d6a10cc68e4f1adc3fed45235 (patch) | |
| tree | 8ed0a4f28637b7609ac6771ecf499f8f2445a52b /compiler/rustc_errors/src/markdown | |
| parent | 5533da2d9f628c161598c74901c2740689d9a2df (diff) | |
| parent | 4f2a03c011dce98a354bf1947814ea9b428d0f1b (diff) | |
| download | rust-fe5235ee0f90f41d6a10cc68e4f1adc3fed45235.tar.gz rust-fe5235ee0f90f41d6a10cc68e4f1adc3fed45235.zip | |
Merge pull request #4224 from rust-lang/rustup-2025-03-11
Automatic Rustup
Diffstat (limited to 'compiler/rustc_errors/src/markdown')
| -rw-r--r-- | compiler/rustc_errors/src/markdown/parse.rs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/compiler/rustc_errors/src/markdown/parse.rs b/compiler/rustc_errors/src/markdown/parse.rs index 7a991a2ace7..f02387d8335 100644 --- a/compiler/rustc_errors/src/markdown/parse.rs +++ b/compiler/rustc_errors/src/markdown/parse.rs @@ -40,11 +40,13 @@ type ParseResult<'a> = Option<Parsed<'a>>; /// Parsing context #[derive(Clone, Copy, Debug, PartialEq)] +// The default values are the most common setting for non top-level parsing: not top block, not at +// line start (yes leading whitespace, not escaped). struct Context { /// If true, we are at a the topmost level (not recursing a nested tt) - top_block: bool, + top_block: bool = false, /// Previous character - prev: Prev, + prev: Prev = Prev::Whitespace, } /// Character class preceding this one @@ -57,14 +59,6 @@ enum Prev { Any, } -impl Default for Context { - /// Most common setting for non top-level parsing: not top block, not at - /// line start (yes leading whitespace, not escaped) - fn default() -> Self { - Self { top_block: false, prev: Prev::Whitespace } - } -} - /// Flags to simple parser function #[derive(Clone, Copy, Debug, PartialEq)] enum ParseOpt { @@ -248,7 +242,7 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> { } let (txt, rest) = parse_to_newline(&buf[1..]); - let ctx = Context { top_block: false, prev: Prev::Whitespace }; + let ctx = Context { .. }; let stream = parse_recursive(txt, ctx); Some((MdTree::Heading(level.try_into().unwrap(), stream), rest)) @@ -257,7 +251,7 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> { /// Bulleted list fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> { let (txt, rest) = get_indented_section(&buf[2..]); - let ctx = Context { top_block: false, prev: Prev::Whitespace }; + let ctx = Context { .. }; let stream = parse_recursive(trim_ascii_start(txt), ctx); (MdTree::UnorderedListItem(stream), rest) } @@ -266,7 +260,7 @@ fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> { 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 { top_block: false, prev: Prev::Whitespace }; + let ctx = Context { .. }; let stream = parse_recursive(trim_ascii_start(txt), ctx); (MdTree::OrderedListItem(num, stream), rest) } |
