1
Fork 0

Rollup merge of #119538 - nnethercote:cleanup-errors-5, r=compiler-errors

Cleanup error handlers: round 5

More rustc_errors cleanups. A sequel to https://github.com/rust-lang/rust/pull/119171.

r? ````@compiler-errors````
This commit is contained in:
Michael Goulet 2024-01-05 10:57:21 -05:00 committed by GitHub
commit f361b591ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 369 additions and 464 deletions

View file

@ -174,7 +174,7 @@ impl<'a> Parser<'a> {
) {
Ok(Some(item)) => {
// FIXME(#100717)
err.set_arg("item", item.kind.descr());
err.arg("item", item.kind.descr());
err.span_label(item.span, fluent::parse_label_does_not_annotate_this);
err.span_suggestion_verbose(
replacement_span,

View file

@ -846,7 +846,7 @@ impl<'a> Parser<'a> {
) =>
{
let n_hashes: u8 = *n_hashes;
err.set_primary_message("too many `#` when terminating raw string");
err.primary_message("too many `#` when terminating raw string");
let str_span = self.prev_token.span;
let mut span = self.token.span;
let mut count = 0;
@ -857,7 +857,7 @@ impl<'a> Parser<'a> {
self.bump();
count += 1;
}
err.set_span(span);
err.span(span);
err.span_suggestion(
span,
format!("remove the extra `#`{}", pluralize!(count)),

View file

@ -925,9 +925,8 @@ impl<'a> Parser<'a> {
});
}
expect_err.set_primary_message(
"closure bodies that contain statements must be surrounded by braces",
);
expect_err
.primary_message("closure bodies that contain statements must be surrounded by braces");
let preceding_pipe_span = closure_spans.closing_pipe;
let following_token_span = self.token.span;
@ -951,7 +950,7 @@ impl<'a> Parser<'a> {
);
expect_err.span_note(second_note, "the closure body may be incorrectly delimited");
expect_err.set_span(vec![preceding_pipe_span, following_token_span]);
expect_err.span(vec![preceding_pipe_span, following_token_span]);
let opening_suggestion_str = " {".to_string();
let closing_suggestion_str = "}".to_string();