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:
parent
c91edc3888
commit
7ba82d61eb
77 changed files with 363 additions and 328 deletions
|
@ -12,7 +12,7 @@ use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind
|
|||
use rustc_attr::{self as attr, Deprecation, Stability};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::sync::{self, Lrc};
|
||||
use rustc_errors::{DiagCtxt, ErrorGuaranteed, PResult};
|
||||
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, PResult};
|
||||
use rustc_feature::Features;
|
||||
use rustc_lint_defs::{BufferedEarlyLint, RegisteredTools};
|
||||
use rustc_parse::{parser::Parser, MACRO_ARGUMENTS};
|
||||
|
@ -1135,7 +1135,7 @@ impl<'a> ExtCtxt<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn dcx(&self) -> &'a DiagCtxt {
|
||||
pub fn dcx(&self) -> DiagCtxtHandle<'a> {
|
||||
self.sess.dcx()
|
||||
}
|
||||
|
||||
|
@ -1256,7 +1256,7 @@ pub fn resolve_path(sess: &Session, path: impl Into<PathBuf>, span: Span) -> PRe
|
|||
}
|
||||
|
||||
pub fn parse_macro_name_and_helper_attrs(
|
||||
dcx: &rustc_errors::DiagCtxt,
|
||||
dcx: DiagCtxtHandle<'_>,
|
||||
attr: &Attribute,
|
||||
macro_type: &str,
|
||||
) -> Option<(Symbol, Vec<Symbol>)> {
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::mbe::{
|
|||
use rustc_ast::token::{self, Token, TokenKind};
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_errors::{Applicability, Diag, DiagCtxt, DiagMessage};
|
||||
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, DiagMessage};
|
||||
use rustc_macros::Subdiagnostic;
|
||||
use rustc_parse::parser::{Parser, Recovery};
|
||||
use rustc_span::source_map::SourceMap;
|
||||
|
@ -324,7 +324,12 @@ enum ExplainDocComment {
|
|||
},
|
||||
}
|
||||
|
||||
pub(super) fn annotate_doc_comment(dcx: &DiagCtxt, err: &mut Diag<'_>, sm: &SourceMap, span: Span) {
|
||||
pub(super) fn annotate_doc_comment(
|
||||
dcx: DiagCtxtHandle<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
sm: &SourceMap,
|
||||
span: Span,
|
||||
) {
|
||||
if let Ok(src) = sm.span_to_snippet(span) {
|
||||
if src.starts_with("///") || src.starts_with("/**") {
|
||||
err.subdiagnostic(dcx, ExplainDocComment::Outer { span });
|
||||
|
|
|
@ -10,7 +10,7 @@ use rustc_ast::token::IdentIsRaw;
|
|||
use rustc_ast::token::{self, Delimiter, Token, TokenKind};
|
||||
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{pluralize, Diag, DiagCtxt, PResult};
|
||||
use rustc_errors::{pluralize, Diag, DiagCtxtHandle, PResult};
|
||||
use rustc_parse::parser::ParseNtResult;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::hygiene::{LocalExpnId, Transparency};
|
||||
|
@ -571,7 +571,7 @@ fn lockstep_iter_size(
|
|||
/// * `[ $( ${count(foo, 1)} ),* ]` will return an error because `${count(foo, 1)}` is
|
||||
/// declared inside a single repetition and the index `1` implies two nested repetitions.
|
||||
fn count_repetitions<'a>(
|
||||
dcx: &'a DiagCtxt,
|
||||
dcx: DiagCtxtHandle<'a>,
|
||||
depth_user: usize,
|
||||
mut matched: &NamedMatch,
|
||||
repeats: &[(usize, usize)],
|
||||
|
@ -632,7 +632,7 @@ fn count_repetitions<'a>(
|
|||
|
||||
/// Returns a `NamedMatch` item declared on the LHS given an arbitrary [Ident]
|
||||
fn matched_from_ident<'ctx, 'interp, 'rslt>(
|
||||
dcx: &'ctx DiagCtxt,
|
||||
dcx: DiagCtxtHandle<'ctx>,
|
||||
ident: Ident,
|
||||
interp: &'interp FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
|
||||
) -> PResult<'ctx, &'rslt NamedMatch>
|
||||
|
@ -646,7 +646,7 @@ where
|
|||
|
||||
/// Used by meta-variable expressions when an user input is out of the actual declared bounds. For
|
||||
/// example, index(999999) in an repetition of only three elements.
|
||||
fn out_of_bounds_err<'a>(dcx: &'a DiagCtxt, max: usize, span: Span, ty: &str) -> Diag<'a> {
|
||||
fn out_of_bounds_err<'a>(dcx: DiagCtxtHandle<'a>, max: usize, span: Span, ty: &str) -> Diag<'a> {
|
||||
let msg = if max == 0 {
|
||||
format!(
|
||||
"meta-variable expression `{ty}` with depth parameter \
|
||||
|
@ -662,7 +662,7 @@ fn out_of_bounds_err<'a>(dcx: &'a DiagCtxt, max: usize, span: Span, ty: &str) ->
|
|||
}
|
||||
|
||||
fn transcribe_metavar_expr<'a>(
|
||||
dcx: &'a DiagCtxt,
|
||||
dcx: DiagCtxtHandle<'a>,
|
||||
expr: &MetaVarExpr,
|
||||
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
|
||||
marker: &mut Marker,
|
||||
|
@ -730,7 +730,7 @@ fn transcribe_metavar_expr<'a>(
|
|||
|
||||
/// Extracts an identifier that can be originated from a `$var:ident` variable or from a token tree.
|
||||
fn extract_ident<'a>(
|
||||
dcx: &'a DiagCtxt,
|
||||
dcx: DiagCtxtHandle<'a>,
|
||||
ident: Ident,
|
||||
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
|
||||
) -> PResult<'a, String> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue