Rename many DiagCtxt
arguments.
This commit is contained in:
parent
4dc7fab56f
commit
f422dca3ae
44 changed files with 317 additions and 353 deletions
|
@ -1042,11 +1042,11 @@ impl<'a> IntoDiagnostic<'a> for ExpectedIdentifier {
|
|||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'a rustc_errors::DiagCtxt,
|
||||
dcx: &'a rustc_errors::DiagCtxt,
|
||||
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let token_descr = TokenDescription::from_token(&self.token);
|
||||
|
||||
let mut diag = handler.struct_err(match token_descr {
|
||||
let mut diag = dcx.struct_err(match token_descr {
|
||||
Some(TokenDescription::ReservedIdentifier) => {
|
||||
fluent::parse_expected_identifier_found_reserved_identifier_str
|
||||
}
|
||||
|
@ -1099,11 +1099,11 @@ impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
|
|||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'a rustc_errors::DiagCtxt,
|
||||
dcx: &'a rustc_errors::DiagCtxt,
|
||||
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let token_descr = TokenDescription::from_token(&self.token);
|
||||
|
||||
let mut diag = handler.struct_err(match token_descr {
|
||||
let mut diag = dcx.struct_err(match token_descr {
|
||||
Some(TokenDescription::ReservedIdentifier) => {
|
||||
fluent::parse_expected_semi_found_reserved_identifier_str
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use rustc_span::{BytePos, Span};
|
|||
use crate::errors::{MoreThanOneCharNote, MoreThanOneCharSugg, NoBraceUnicodeSub, UnescapeError};
|
||||
|
||||
pub(crate) fn emit_unescape_error(
|
||||
handler: &DiagCtxt,
|
||||
dcx: &DiagCtxt,
|
||||
// interior part of the literal, between quotes
|
||||
lit: &str,
|
||||
// full span of the literal, including quotes and any prefix
|
||||
|
@ -33,12 +33,10 @@ pub(crate) fn emit_unescape_error(
|
|||
};
|
||||
match error {
|
||||
EscapeError::LoneSurrogateUnicodeEscape => {
|
||||
handler
|
||||
.emit_err(UnescapeError::InvalidUnicodeEscape { span: err_span, surrogate: true });
|
||||
dcx.emit_err(UnescapeError::InvalidUnicodeEscape { span: err_span, surrogate: true });
|
||||
}
|
||||
EscapeError::OutOfRangeUnicodeEscape => {
|
||||
handler
|
||||
.emit_err(UnescapeError::InvalidUnicodeEscape { span: err_span, surrogate: false });
|
||||
dcx.emit_err(UnescapeError::InvalidUnicodeEscape { span: err_span, surrogate: false });
|
||||
}
|
||||
EscapeError::MoreThanOneChar => {
|
||||
use unicode_normalization::{char::is_combining_mark, UnicodeNormalization};
|
||||
|
@ -104,7 +102,7 @@ pub(crate) fn emit_unescape_error(
|
|||
sugg,
|
||||
}
|
||||
});
|
||||
handler.emit_err(UnescapeError::MoreThanOneChar {
|
||||
dcx.emit_err(UnescapeError::MoreThanOneChar {
|
||||
span: full_lit_span,
|
||||
note,
|
||||
suggestion: sugg,
|
||||
|
@ -112,7 +110,7 @@ pub(crate) fn emit_unescape_error(
|
|||
}
|
||||
EscapeError::EscapeOnlyChar => {
|
||||
let (c, char_span) = last_char();
|
||||
handler.emit_err(UnescapeError::EscapeOnlyChar {
|
||||
dcx.emit_err(UnescapeError::EscapeOnlyChar {
|
||||
span: err_span,
|
||||
char_span,
|
||||
escaped_sugg: c.escape_default().to_string(),
|
||||
|
@ -122,11 +120,11 @@ pub(crate) fn emit_unescape_error(
|
|||
}
|
||||
EscapeError::BareCarriageReturn => {
|
||||
let double_quotes = mode.in_double_quotes();
|
||||
handler.emit_err(UnescapeError::BareCr { span: err_span, double_quotes });
|
||||
dcx.emit_err(UnescapeError::BareCr { span: err_span, double_quotes });
|
||||
}
|
||||
EscapeError::BareCarriageReturnInRawString => {
|
||||
assert!(mode.in_double_quotes());
|
||||
handler.emit_err(UnescapeError::BareCrRawString(err_span));
|
||||
dcx.emit_err(UnescapeError::BareCrRawString(err_span));
|
||||
}
|
||||
EscapeError::InvalidEscape => {
|
||||
let (c, span) = last_char();
|
||||
|
@ -137,7 +135,7 @@ pub(crate) fn emit_unescape_error(
|
|||
"unknown character escape"
|
||||
};
|
||||
let ec = escaped_char(c);
|
||||
let mut diag = handler.struct_span_err(span, format!("{label}: `{ec}`"));
|
||||
let mut diag = dcx.struct_span_err(span, format!("{label}: `{ec}`"));
|
||||
diag.span_label(span, label);
|
||||
if c == '{' || c == '}' && matches!(mode, Mode::Str | Mode::RawStr) {
|
||||
diag.help(
|
||||
|
@ -166,13 +164,13 @@ pub(crate) fn emit_unescape_error(
|
|||
diag.emit();
|
||||
}
|
||||
EscapeError::TooShortHexEscape => {
|
||||
handler.emit_err(UnescapeError::TooShortHexEscape(err_span));
|
||||
dcx.emit_err(UnescapeError::TooShortHexEscape(err_span));
|
||||
}
|
||||
EscapeError::InvalidCharInHexEscape | EscapeError::InvalidCharInUnicodeEscape => {
|
||||
let (c, span) = last_char();
|
||||
let is_hex = error == EscapeError::InvalidCharInHexEscape;
|
||||
let ch = escaped_char(c);
|
||||
handler.emit_err(UnescapeError::InvalidCharInEscape { span, is_hex, ch });
|
||||
dcx.emit_err(UnescapeError::InvalidCharInEscape { span, is_hex, ch });
|
||||
}
|
||||
EscapeError::NonAsciiCharInByte => {
|
||||
let (c, span) = last_char();
|
||||
|
@ -182,7 +180,7 @@ pub(crate) fn emit_unescape_error(
|
|||
Mode::RawByteStr => "raw byte string literal",
|
||||
_ => panic!("non-is_byte literal paired with NonAsciiCharInByte"),
|
||||
};
|
||||
let mut err = handler.struct_span_err(span, format!("non-ASCII character in {desc}"));
|
||||
let mut err = dcx.struct_span_err(span, format!("non-ASCII character in {desc}"));
|
||||
let postfix = if unicode_width::UnicodeWidthChar::width(c).unwrap_or(1) == 0 {
|
||||
format!(" but is {c:?}")
|
||||
} else {
|
||||
|
@ -218,21 +216,20 @@ pub(crate) fn emit_unescape_error(
|
|||
err.emit();
|
||||
}
|
||||
EscapeError::OutOfRangeHexEscape => {
|
||||
handler.emit_err(UnescapeError::OutOfRangeHexEscape(err_span));
|
||||
dcx.emit_err(UnescapeError::OutOfRangeHexEscape(err_span));
|
||||
}
|
||||
EscapeError::LeadingUnderscoreUnicodeEscape => {
|
||||
let (c, span) = last_char();
|
||||
handler.emit_err(UnescapeError::LeadingUnderscoreUnicodeEscape {
|
||||
dcx.emit_err(UnescapeError::LeadingUnderscoreUnicodeEscape {
|
||||
span,
|
||||
ch: escaped_char(c),
|
||||
});
|
||||
}
|
||||
EscapeError::OverlongUnicodeEscape => {
|
||||
handler.emit_err(UnescapeError::OverlongUnicodeEscape(err_span));
|
||||
dcx.emit_err(UnescapeError::OverlongUnicodeEscape(err_span));
|
||||
}
|
||||
EscapeError::UnclosedUnicodeEscape => {
|
||||
handler
|
||||
.emit_err(UnescapeError::UnclosedUnicodeEscape(err_span, err_span.shrink_to_hi()));
|
||||
dcx.emit_err(UnescapeError::UnclosedUnicodeEscape(err_span, err_span.shrink_to_hi()));
|
||||
}
|
||||
EscapeError::NoBraceInUnicodeEscape => {
|
||||
let mut suggestion = "\\u{".to_owned();
|
||||
|
@ -251,30 +248,30 @@ pub(crate) fn emit_unescape_error(
|
|||
} else {
|
||||
(Some(err_span), NoBraceUnicodeSub::Help)
|
||||
};
|
||||
handler.emit_err(UnescapeError::NoBraceInUnicodeEscape { span: err_span, label, sub });
|
||||
dcx.emit_err(UnescapeError::NoBraceInUnicodeEscape { span: err_span, label, sub });
|
||||
}
|
||||
EscapeError::UnicodeEscapeInByte => {
|
||||
handler.emit_err(UnescapeError::UnicodeEscapeInByte(err_span));
|
||||
dcx.emit_err(UnescapeError::UnicodeEscapeInByte(err_span));
|
||||
}
|
||||
EscapeError::EmptyUnicodeEscape => {
|
||||
handler.emit_err(UnescapeError::EmptyUnicodeEscape(err_span));
|
||||
dcx.emit_err(UnescapeError::EmptyUnicodeEscape(err_span));
|
||||
}
|
||||
EscapeError::ZeroChars => {
|
||||
handler.emit_err(UnescapeError::ZeroChars(err_span));
|
||||
dcx.emit_err(UnescapeError::ZeroChars(err_span));
|
||||
}
|
||||
EscapeError::LoneSlash => {
|
||||
handler.emit_err(UnescapeError::LoneSlash(err_span));
|
||||
dcx.emit_err(UnescapeError::LoneSlash(err_span));
|
||||
}
|
||||
EscapeError::UnskippedWhitespaceWarning => {
|
||||
let (c, char_span) = last_char();
|
||||
handler.emit_warning(UnescapeError::UnskippedWhitespace {
|
||||
dcx.emit_warning(UnescapeError::UnskippedWhitespace {
|
||||
span: err_span,
|
||||
ch: escaped_char(c),
|
||||
char_span,
|
||||
});
|
||||
}
|
||||
EscapeError::MultipleSkippedLinesWarning => {
|
||||
handler.emit_warning(UnescapeError::MultipleSkippedLinesWarning(err_span));
|
||||
dcx.emit_warning(UnescapeError::MultipleSkippedLinesWarning(err_span));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue