Skip to content

Commit 03eb454

Browse files
committedMar 7, 2025
Auto merge of rust-lang#138155 - matthiaskrgr:rollup-xq5buio, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#137674 (Enable `f16` for LoongArch) - rust-lang#138034 (library: Use `size_of` from the prelude instead of imported) - rust-lang#138060 (Revert rust-lang#138019 after further discussion about how hir-pretty printing should work) - rust-lang#138073 (Break critical edges in inline asm before code generation) - rust-lang#138107 (`librustdoc`: clippy fixes) - rust-lang#138111 (Use `default_field_values` for `rustc_errors::Context`, `rustc_session::config::NextSolverConfig` and `rustc_session::config::ErrorOutputType`) r? `@ghost` `@rustbot` modify labels: rollup

File tree

145 files changed

+579
-691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+579
-691
lines changed
 

‎compiler/rustc_errors/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![feature(associated_type_defaults)]
1515
#![feature(box_into_inner)]
1616
#![feature(box_patterns)]
17+
#![feature(default_field_values)]
1718
#![feature(error_reporter)]
1819
#![feature(if_let_guard)]
1920
#![feature(let_chains)]

‎compiler/rustc_errors/src/markdown/parse.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ type ParseResult<'a> = Option<Parsed<'a>>;
4040

4141
/// Parsing context
4242
#[derive(Clone, Copy, Debug, PartialEq)]
43+
// The default values are the most common setting for non top-level parsing: not top block, not at
44+
// line start (yes leading whitespace, not escaped).
4345
struct Context {
4446
/// If true, we are at a the topmost level (not recursing a nested tt)
45-
top_block: bool,
47+
top_block: bool = false,
4648
/// Previous character
47-
prev: Prev,
49+
prev: Prev = Prev::Whitespace,
4850
}
4951

5052
/// Character class preceding this one
@@ -57,14 +59,6 @@ enum Prev {
5759
Any,
5860
}
5961

60-
impl Default for Context {
61-
/// Most common setting for non top-level parsing: not top block, not at
62-
/// line start (yes leading whitespace, not escaped)
63-
fn default() -> Self {
64-
Self { top_block: false, prev: Prev::Whitespace }
65-
}
66-
}
67-
6862
/// Flags to simple parser function
6963
#[derive(Clone, Copy, Debug, PartialEq)]
7064
enum ParseOpt {
@@ -248,7 +242,7 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> {
248242
}
249243

250244
let (txt, rest) = parse_to_newline(&buf[1..]);
251-
let ctx = Context { top_block: false, prev: Prev::Whitespace };
245+
let ctx = Context { .. };
252246
let stream = parse_recursive(txt, ctx);
253247

254248
Some((MdTree::Heading(level.try_into().unwrap(), stream), rest))
@@ -257,7 +251,7 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> {
257251
/// Bulleted list
258252
fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> {
259253
let (txt, rest) = get_indented_section(&buf[2..]);
260-
let ctx = Context { top_block: false, prev: Prev::Whitespace };
254+
let ctx = Context { .. };
261255
let stream = parse_recursive(trim_ascii_start(txt), ctx);
262256
(MdTree::UnorderedListItem(stream), rest)
263257
}
@@ -266,7 +260,7 @@ fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> {
266260
fn parse_ordered_li(buf: &[u8]) -> Parsed<'_> {
267261
let (num, pos) = ord_list_start(buf).unwrap(); // success tested in caller
268262
let (txt, rest) = get_indented_section(&buf[pos..]);
269-
let ctx = Context { top_block: false, prev: Prev::Whitespace };
263+
let ctx = Context { .. };
270264
let stream = parse_recursive(trim_ascii_start(txt), ctx);
271265
(MdTree::OrderedListItem(num, stream), rest)
272266
}

0 commit comments

Comments
 (0)