1
Fork 0

Rename Session::span_diagnostic as Session::dcx.

This commit is contained in:
Nicholas Nethercote 2023-12-18 06:21:26 +11:00
parent 9df1576e1d
commit 09af8a667c
66 changed files with 176 additions and 204 deletions

View file

@ -790,7 +790,7 @@ impl SyntaxExtension {
.map(|attr| {
// Override `helper_attrs` passed above if it's a built-in macro,
// marking `proc_macro_derive` macros as built-in is not a realistic use case.
parse_macro_name_and_helper_attrs(sess.diagnostic(), attr, "built-in").map_or_else(
parse_macro_name_and_helper_attrs(sess.dcx(), attr, "built-in").map_or_else(
|| (Some(name), Vec::new()),
|(name, helper_attrs)| (Some(name), helper_attrs),
)
@ -1119,7 +1119,7 @@ impl<'a> ExtCtxt<'a> {
sp: S,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
self.sess.diagnostic().struct_span_err(sp, msg)
self.sess.dcx().struct_span_err(sp, msg)
}
#[track_caller]
@ -1143,10 +1143,10 @@ impl<'a> ExtCtxt<'a> {
#[rustc_lint_diagnostics]
#[track_caller]
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
self.sess.diagnostic().span_err(sp, msg);
self.sess.dcx().span_err(sp, msg);
}
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) -> ! {
self.sess.diagnostic().span_bug(sp, msg);
self.sess.dcx().span_bug(sp, msg);
}
pub fn trace_macros_diag(&mut self) {
for (span, notes) in self.expansions.iter() {
@ -1160,7 +1160,7 @@ impl<'a> ExtCtxt<'a> {
self.expansions.clear();
}
pub fn bug(&self, msg: &'static str) -> ! {
self.sess.diagnostic().bug(msg);
self.sess.dcx().bug(msg);
}
pub fn trace_macros(&self) -> bool {
self.ecfg.trace_mac

View file

@ -482,14 +482,14 @@ pub fn compile_declarative_macro(
let s = parse_failure_msg(&token);
let sp = token.span.substitute_dummy(def.span);
let mut err = sess.diagnostic().struct_span_err(sp, s);
let mut err = sess.dcx().struct_span_err(sp, s);
err.span_label(sp, msg);
annotate_doc_comment(&mut err, sess.source_map(), sp);
err.emit();
return dummy_syn_ext();
}
Error(sp, msg) => {
sess.diagnostic().struct_span_err(sp.substitute_dummy(def.span), msg).emit();
sess.dcx().struct_span_err(sp.substitute_dummy(def.span), msg).emit();
return dummy_syn_ext();
}
ErrorReported(_) => {
@ -518,10 +518,10 @@ pub fn compile_declarative_macro(
valid &= check_lhs_nt_follows(&sess.parse_sess, def, &tt);
return tt;
}
sess.diagnostic().span_bug(def.span, "wrong-structured lhs")
sess.dcx().span_bug(def.span, "wrong-structured lhs")
})
.collect::<Vec<mbe::TokenTree>>(),
_ => sess.diagnostic().span_bug(def.span, "wrong-structured lhs"),
_ => sess.dcx().span_bug(def.span, "wrong-structured lhs"),
};
let rhses = match &argument_map[&MacroRulesNormalizedIdent::new(rhs_nm)] {
@ -540,10 +540,10 @@ pub fn compile_declarative_macro(
.pop()
.unwrap();
}
sess.diagnostic().span_bug(def.span, "wrong-structured rhs")
sess.dcx().span_bug(def.span, "wrong-structured rhs")
})
.collect::<Vec<mbe::TokenTree>>(),
_ => sess.diagnostic().span_bug(def.span, "wrong-structured rhs"),
_ => sess.dcx().span_bug(def.span, "wrong-structured rhs"),
};
for rhs in &rhses {
@ -599,7 +599,7 @@ pub fn compile_declarative_macro(
mbe::TokenTree::Delimited(.., delimited) => {
mbe::macro_parser::compute_locs(&delimited.tts)
}
_ => sess.diagnostic().span_bug(def.span, "malformed macro lhs"),
_ => sess.dcx().span_bug(def.span, "malformed macro lhs"),
}
})
.collect()

View file

@ -156,7 +156,7 @@ impl MultiItemModifier for DeriveProcMacro {
}
};
let error_count_before = ecx.sess.diagnostic().err_count();
let error_count_before = ecx.sess.dcx().err_count();
let mut parser =
rustc_parse::stream_to_parser(&ecx.sess.parse_sess, stream, Some("proc-macro derive"));
let mut items = vec![];
@ -179,7 +179,7 @@ impl MultiItemModifier for DeriveProcMacro {
}
// fail if there have been errors emitted
if ecx.sess.diagnostic().err_count() > error_count_before {
if ecx.sess.dcx().err_count() > error_count_before {
ecx.sess.emit_err(errors::ProcMacroDeriveTokens { span });
}