UPDATE - rename DiagnosticHandler trait to IntoDiagnostic
This commit is contained in:
parent
5b8152807c
commit
19b348fed4
46 changed files with 659 additions and 584 deletions
|
@ -8,7 +8,7 @@ use rustc_span::{Span, Symbol};
|
|||
use rustc_target::abi::TargetDataLayoutErrors;
|
||||
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[derive(DiagnosticHandler)]
|
||||
#[diag(session::incorrect_cgu_reuse_type)]
|
||||
pub struct IncorrectCguReuseType<'a> {
|
||||
#[primary_span]
|
||||
|
@ -19,14 +19,14 @@ pub struct IncorrectCguReuseType<'a> {
|
|||
pub at_least: u8,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[derive(DiagnosticHandler)]
|
||||
#[diag(session::cgu_not_recorded)]
|
||||
pub struct CguNotRecorded<'a> {
|
||||
pub cgu_user_name: &'a str,
|
||||
pub cgu_name: &'a str,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[derive(DiagnosticHandler)]
|
||||
#[diag(session::feature_gate_error, code = "E0658")]
|
||||
pub struct FeatureGateError<'a> {
|
||||
#[primary_span]
|
||||
|
@ -46,19 +46,19 @@ pub struct FeatureDiagnosticHelp {
|
|||
pub feature: Symbol,
|
||||
}
|
||||
|
||||
impl SessionDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
|
||||
fn into_diagnostic(self, sess: &Handler) -> DiagnosticBuilder<'_, !> {
|
||||
impl DiagnosticHandler<'_, !> for TargetDataLayoutErrors<'_> {
|
||||
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
|
||||
let mut diag;
|
||||
match self {
|
||||
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
||||
diag = sess.struct_fatal(fluent::session::target_invalid_address_space);
|
||||
diag = handler.struct_fatal(fluent::session::target_invalid_address_space);
|
||||
diag.set_arg("addr_space", addr_space);
|
||||
diag.set_arg("cause", cause);
|
||||
diag.set_arg("err", err);
|
||||
diag
|
||||
}
|
||||
TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => {
|
||||
diag = sess.struct_fatal(fluent::session::target_invalid_bits);
|
||||
diag = handler.struct_fatal(fluent::session::target_invalid_bits);
|
||||
diag.set_arg("kind", kind);
|
||||
diag.set_arg("bit", bit);
|
||||
diag.set_arg("cause", cause);
|
||||
|
@ -66,30 +66,30 @@ impl SessionDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
|
|||
diag
|
||||
}
|
||||
TargetDataLayoutErrors::MissingAlignment { cause } => {
|
||||
diag = sess.struct_fatal(fluent::session::target_missing_alignment);
|
||||
diag = handler.struct_fatal(fluent::session::target_missing_alignment);
|
||||
diag.set_arg("cause", cause);
|
||||
diag
|
||||
}
|
||||
TargetDataLayoutErrors::InvalidAlignment { cause, err } => {
|
||||
diag = sess.struct_fatal(fluent::session::target_invalid_alignment);
|
||||
diag = handler.struct_fatal(fluent::session::target_invalid_alignment);
|
||||
diag.set_arg("cause", cause);
|
||||
diag.set_arg("err", err);
|
||||
diag
|
||||
}
|
||||
TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => {
|
||||
diag = sess.struct_fatal(fluent::session::target_inconsistent_architecture);
|
||||
diag = handler.struct_fatal(fluent::session::target_inconsistent_architecture);
|
||||
diag.set_arg("dl", dl);
|
||||
diag.set_arg("target", target);
|
||||
diag
|
||||
}
|
||||
TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => {
|
||||
diag = sess.struct_fatal(fluent::session::target_inconsistent_pointer_width);
|
||||
diag = handler.struct_fatal(fluent::session::target_inconsistent_pointer_width);
|
||||
diag.set_arg("pointer_size", pointer_size);
|
||||
diag.set_arg("target", target);
|
||||
diag
|
||||
}
|
||||
TargetDataLayoutErrors::InvalidBitsSize { err } => {
|
||||
diag = sess.struct_fatal(fluent::session::target_invalid_bits_size);
|
||||
diag = handler.struct_fatal(fluent::session::target_invalid_bits_size);
|
||||
diag.set_arg("err", err);
|
||||
diag
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
|||
use rustc_data_structures::sync::{Lock, Lrc};
|
||||
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
|
||||
use rustc_errors::{
|
||||
fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId,
|
||||
DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, MultiSpan, SessionDiagnostic, StashKey,
|
||||
fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder, IntoDiagnostic,
|
||||
DiagnosticId, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, MultiSpan, StashKey,
|
||||
};
|
||||
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
|
||||
use rustc_span::edition::Edition;
|
||||
|
@ -344,34 +344,34 @@ impl ParseSess {
|
|||
|
||||
pub fn create_err<'a>(
|
||||
&'a self,
|
||||
err: impl SessionDiagnostic<'a>,
|
||||
err: impl IntoDiagnostic<'a>,
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
err.into_diagnostic(&self.span_diagnostic)
|
||||
}
|
||||
|
||||
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
|
||||
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
|
||||
self.create_err(err).emit()
|
||||
}
|
||||
|
||||
pub fn create_warning<'a>(
|
||||
&'a self,
|
||||
warning: impl SessionDiagnostic<'a, ()>,
|
||||
warning: impl IntoDiagnostic<'a, ()>,
|
||||
) -> DiagnosticBuilder<'a, ()> {
|
||||
warning.into_diagnostic(&self.span_diagnostic)
|
||||
}
|
||||
|
||||
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
|
||||
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
|
||||
self.create_warning(warning).emit()
|
||||
}
|
||||
|
||||
pub fn create_fatal<'a>(
|
||||
&'a self,
|
||||
fatal: impl SessionDiagnostic<'a, !>,
|
||||
fatal: impl IntoDiagnostic<'a, !>,
|
||||
) -> DiagnosticBuilder<'a, !> {
|
||||
fatal.into_diagnostic(&self.span_diagnostic)
|
||||
}
|
||||
|
||||
pub fn emit_fatal<'a>(&'a self, fatal: impl SessionDiagnostic<'a, !>) -> ! {
|
||||
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
|
||||
self.create_fatal(fatal).emit()
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
|
|||
use rustc_errors::json::JsonEmitter;
|
||||
use rustc_errors::registry::Registry;
|
||||
use rustc_errors::{
|
||||
error_code, fallback_fluent_bundle, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
|
||||
ErrorGuaranteed, FluentBundle, LazyFallbackBundle, MultiSpan, SessionDiagnostic,
|
||||
error_code, fallback_fluent_bundle, DiagnosticBuilder, IntoDiagnostic, DiagnosticId,
|
||||
DiagnosticMessage, ErrorGuaranteed, FluentBundle, LazyFallbackBundle, MultiSpan,
|
||||
};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
pub use rustc_span::def_id::StableCrateId;
|
||||
|
@ -505,13 +505,13 @@ impl Session {
|
|||
}
|
||||
pub fn create_err<'a>(
|
||||
&'a self,
|
||||
err: impl SessionDiagnostic<'a>,
|
||||
err: impl IntoDiagnostic<'a>,
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
self.parse_sess.create_err(err)
|
||||
}
|
||||
pub fn create_feature_err<'a>(
|
||||
&'a self,
|
||||
err: impl SessionDiagnostic<'a>,
|
||||
err: impl IntoDiagnostic<'a>,
|
||||
feature: Symbol,
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let mut err = self.parse_sess.create_err(err);
|
||||
|
@ -521,25 +521,25 @@ impl Session {
|
|||
add_feature_diagnostics(&mut err, &self.parse_sess, feature);
|
||||
err
|
||||
}
|
||||
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
|
||||
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
|
||||
self.parse_sess.emit_err(err)
|
||||
}
|
||||
pub fn create_warning<'a>(
|
||||
&'a self,
|
||||
err: impl SessionDiagnostic<'a, ()>,
|
||||
err: impl IntoDiagnostic<'a, ()>,
|
||||
) -> DiagnosticBuilder<'a, ()> {
|
||||
self.parse_sess.create_warning(err)
|
||||
}
|
||||
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
|
||||
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
|
||||
self.parse_sess.emit_warning(warning)
|
||||
}
|
||||
pub fn create_fatal<'a>(
|
||||
&'a self,
|
||||
fatal: impl SessionDiagnostic<'a, !>,
|
||||
fatal: impl IntoDiagnostic<'a, !>,
|
||||
) -> DiagnosticBuilder<'a, !> {
|
||||
self.parse_sess.create_fatal(fatal)
|
||||
}
|
||||
pub fn emit_fatal<'a>(&'a self, fatal: impl SessionDiagnostic<'a, !>) -> ! {
|
||||
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
|
||||
self.parse_sess.emit_fatal(fatal)
|
||||
}
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue