Use a dedicated type instead of a reference for the diagnostic context

This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
This commit is contained in:
Oli Scherer
2024-06-18 10:35:56 +00:00
parent c91edc3888
commit 7ba82d61eb
77 changed files with 363 additions and 328 deletions

View File

@@ -7,7 +7,7 @@ use rustc_ast::ast::{self, AttrStyle};
use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Token, TokenKind};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::util::unicode::contains_text_flow_control_chars;
use rustc_errors::{codes::*, Applicability, Diag, DiagCtxt, StashKey};
use rustc_errors::{codes::*, Applicability, Diag, DiagCtxtHandle, StashKey};
use rustc_lexer::unescape::{self, EscapeError, Mode};
use rustc_lexer::{Base, DocStyle, RawStrError};
use rustc_lexer::{Cursor, LiteralKind};
@@ -113,7 +113,7 @@ struct StringReader<'psess, 'src> {
}
impl<'psess, 'src> StringReader<'psess, 'src> {
fn dcx(&self) -> &'psess DiagCtxt {
fn dcx(&self) -> DiagCtxtHandle<'psess> {
self.psess.dcx()
}

View File

@@ -3,7 +3,7 @@
use std::iter::once;
use std::ops::Range;
use rustc_errors::{Applicability, DiagCtxt, ErrorGuaranteed};
use rustc_errors::{Applicability, DiagCtxtHandle, ErrorGuaranteed};
use rustc_lexer::unescape::{EscapeError, Mode};
use rustc_span::{BytePos, Span};
use tracing::debug;
@@ -11,7 +11,7 @@ use tracing::debug;
use crate::errors::{MoreThanOneCharNote, MoreThanOneCharSugg, NoBraceUnicodeSub, UnescapeError};
pub(crate) fn emit_unescape_error(
dcx: &DiagCtxt,
dcx: DiagCtxtHandle<'_>,
// interior part of the literal, between quotes
lit: &str,
// full span of the literal, including quotes and any prefix