Skip to content

Commit 2ced8b3

Browse files
authored
Rollup merge of rust-lang#134187 - nnethercote:rm-PErr, r=jieyouxu
Remove `PErr`. It's just a synonym for `Diag` that adds no value and is only used in a few places. r? ``@spastorino``
2 parents 1055659 + 40c9645 commit 2ced8b3

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

Diff for: compiler/rustc_errors/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ mod styled_buffer;
9494
mod tests;
9595
pub mod translation;
9696

97-
pub type PErr<'a> = Diag<'a>;
98-
pub type PResult<'a, T> = Result<T, PErr<'a>>;
97+
pub type PResult<'a, T> = Result<T, Diag<'a>>;
9998

10099
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
101100

Diff for: compiler/rustc_parse/src/lexer/tokentrees.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_ast::token::{self, Delimiter, Token};
22
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
33
use rustc_ast_pretty::pprust::token_to_string;
4-
use rustc_errors::{Applicability, PErr};
4+
use rustc_errors::{Applicability, Diag};
55
use rustc_span::symbol::kw;
66

77
use super::diagnostics::{report_suspicious_mismatch_block, same_indentation_level};
@@ -14,7 +14,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
1414
pub(super) fn lex_token_trees(
1515
&mut self,
1616
is_delimited: bool,
17-
) -> (Spacing, TokenStream, Result<(), Vec<PErr<'psess>>>) {
17+
) -> (Spacing, TokenStream, Result<(), Vec<Diag<'psess>>>) {
1818
// Move past the opening delimiter.
1919
let open_spacing = self.bump_minimal();
2020

@@ -56,7 +56,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
5656
}
5757
}
5858

59-
fn eof_err(&mut self) -> PErr<'psess> {
59+
fn eof_err(&mut self) -> Diag<'psess> {
6060
let msg = "this file contains an unclosed delimiter";
6161
let mut err = self.dcx().struct_span_err(self.token.span, msg);
6262

@@ -98,7 +98,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
9898
fn lex_token_tree_open_delim(
9999
&mut self,
100100
open_delim: Delimiter,
101-
) -> Result<TokenTree, Vec<PErr<'psess>>> {
101+
) -> Result<TokenTree, Vec<Diag<'psess>>> {
102102
// The span for beginning of the delimited section.
103103
let pre_span = self.token.span;
104104

@@ -250,8 +250,8 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
250250
fn unclosed_delim_err(
251251
&mut self,
252252
tts: TokenStream,
253-
mut errs: Vec<PErr<'psess>>,
254-
) -> Vec<PErr<'psess>> {
253+
mut errs: Vec<Diag<'psess>>,
254+
) -> Vec<Diag<'psess>> {
255255
// If there are unclosed delims, see if there are diff markers and if so, point them
256256
// out instead of complaining about the unclosed delims.
257257
let mut parser = Parser::new(self.psess, tts, None);
@@ -308,7 +308,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
308308
errs
309309
}
310310

311-
fn close_delim_err(&mut self, delim: Delimiter) -> PErr<'psess> {
311+
fn close_delim_err(&mut self, delim: Delimiter) -> Diag<'psess> {
312312
// An unexpected closing delimiter (i.e., there is no matching opening delimiter).
313313
let token_str = token_to_string(&self.token);
314314
let msg = format!("unexpected closing delimiter: `{token_str}`");

Diff for: compiler/rustc_parse/src/parser/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_ast_pretty::pprust;
1616
use rustc_data_structures::fx::FxHashSet;
1717
use rustc_data_structures::sync::Lrc;
1818
use rustc_errors::{
19-
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, PErr, PResult, Subdiagnostic,
19+
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, PResult, Subdiagnostic,
2020
Suggestions, pluralize,
2121
};
2222
use rustc_session::errors::ExprParenthesesNeeded;
@@ -2132,7 +2132,7 @@ impl<'a> Parser<'a> {
21322132
&mut self,
21332133
delim: Delimiter,
21342134
lo: Span,
2135-
err: PErr<'a>,
2135+
err: Diag<'a>,
21362136
) -> P<Expr> {
21372137
let guar = err.emit();
21382138
// Recover from parse error, callers expect the closing delim to be consumed.
@@ -3014,7 +3014,7 @@ impl<'a> Parser<'a> {
30143014
}
30153015

30163016
/// Check for exclusive ranges written as `..<`
3017-
pub(crate) fn maybe_err_dotdotlt_syntax(&self, maybe_lt: Token, mut err: PErr<'a>) -> PErr<'a> {
3017+
pub(crate) fn maybe_err_dotdotlt_syntax(&self, maybe_lt: Token, mut err: Diag<'a>) -> Diag<'a> {
30183018
if maybe_lt == token::Lt
30193019
&& (self.expected_tokens.contains(&TokenType::Token(token::Gt))
30203020
|| matches!(self.token.kind, token::Literal(..)))

0 commit comments

Comments
 (0)