mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Rename AddToDiagnostic
as Subdiagnostic
.
To match `derive(Subdiagnostic)`. Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
This commit is contained in:
parent
7a294e998b
commit
541d7cc65c
@ -1,5 +1,5 @@
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp,
|
||||
codes::*, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::{symbol::Ident, Span, Symbol};
|
||||
@ -40,8 +40,8 @@ pub struct InvalidAbi {
|
||||
|
||||
pub struct InvalidAbiReason(pub &'static str);
|
||||
|
||||
impl AddToDiagnostic for InvalidAbiReason {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for InvalidAbiReason {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use rustc_ast::ParamKindOrd;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, EmissionGuarantee, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::{symbol::Ident, Span, Symbol};
|
||||
@ -373,8 +373,8 @@ pub struct ArgsBeforeConstraint {
|
||||
pub struct EmptyLabelManySpans(pub Vec<Span>);
|
||||
|
||||
// The derive for `Vec<Span>` does multiple calls to `span_label`, adding commas between each
|
||||
impl AddToDiagnostic for EmptyLabelManySpans {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for EmptyLabelManySpans {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
@ -742,8 +742,8 @@ pub struct StableFeature {
|
||||
pub since: Symbol,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for StableFeature {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for StableFeature {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level, MultiSpan,
|
||||
SingleLabelManySpans, SubdiagMessageOp,
|
||||
codes::*, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level, MultiSpan,
|
||||
SingleLabelManySpans, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::{symbol::Ident, Span, Symbol};
|
||||
@ -589,8 +589,8 @@ pub(crate) struct FormatUnusedArg {
|
||||
|
||||
// Allow the singular form to be a subdiagnostic of the multiple-unused
|
||||
// form of diagnostic.
|
||||
impl AddToDiagnostic for FormatUnusedArg {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for FormatUnusedArg {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
|
@ -170,19 +170,19 @@ impl Into<FluentValue<'static>> for DiagArgValue {
|
||||
|
||||
/// Trait implemented by error types. This should not be implemented manually. Instead, use
|
||||
/// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic].
|
||||
#[rustc_diagnostic_item = "AddToDiagnostic"]
|
||||
pub trait AddToDiagnostic
|
||||
#[rustc_diagnostic_item = "Subdiagnostic"]
|
||||
pub trait Subdiagnostic
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
/// Add a subdiagnostic to an existing diagnostic.
|
||||
fn add_to_diagnostic<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
self.add_to_diagnostic_with(diag, |_, m| m);
|
||||
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
self.add_to_diag_with(diag, |_, m| m);
|
||||
}
|
||||
|
||||
/// Add a subdiagnostic to an existing diagnostic where `f` is invoked on every message used
|
||||
/// (to optionally perform eager translation).
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -1194,9 +1194,9 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn subdiagnostic(
|
||||
&mut self,
|
||||
dcx: &crate::DiagCtxt,
|
||||
subdiagnostic: impl AddToDiagnostic,
|
||||
subdiagnostic: impl Subdiagnostic,
|
||||
) -> &mut Self {
|
||||
subdiagnostic.add_to_diagnostic_with(self, |diag, msg| {
|
||||
subdiagnostic.add_to_diag_with(self, |diag, msg| {
|
||||
let args = diag.args.iter();
|
||||
let msg = diag.subdiagnostic_message_to_diagnostic_message(msg);
|
||||
dcx.eagerly_translate(msg, args)
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::diagnostic::DiagLocation;
|
||||
use crate::{fluent_generated as fluent, AddToDiagnostic};
|
||||
use crate::{fluent_generated as fluent, Subdiagnostic};
|
||||
use crate::{
|
||||
Diag, DiagArgValue, DiagCtxt, Diagnostic, EmissionGuarantee, ErrCode, IntoDiagArg, Level,
|
||||
SubdiagMessageOp,
|
||||
@ -297,8 +297,8 @@ pub struct SingleLabelManySpans {
|
||||
pub spans: Vec<Span>,
|
||||
pub label: &'static str,
|
||||
}
|
||||
impl AddToDiagnostic for SingleLabelManySpans {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for SingleLabelManySpans {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
|
@ -37,9 +37,9 @@ extern crate self as rustc_errors;
|
||||
|
||||
pub use codes::*;
|
||||
pub use diagnostic::{
|
||||
AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue,
|
||||
DiagInner, DiagStyledString, Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg,
|
||||
StringPart, Subdiag, SubdiagMessageOp,
|
||||
BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner,
|
||||
DiagStyledString, Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg, StringPart, Subdiag,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
pub use diagnostic_impls::{
|
||||
DiagArgFromDisplay, DiagSymbolList, ExpectedLifetimeParameter, IndicateAnonymousLifetime,
|
||||
|
@ -3,8 +3,8 @@ use std::borrow::Cow;
|
||||
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagArgValue, EmissionGuarantee, IntoDiagArg,
|
||||
MultiSpan, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagArgValue, EmissionGuarantee, IntoDiagArg, MultiSpan,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::Ty;
|
||||
@ -194,8 +194,8 @@ pub struct TypeMismatchFruTypo {
|
||||
pub expr: Option<String>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for TypeMismatchFruTypo {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for TypeMismatchFruTypo {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -373,8 +373,8 @@ pub struct RemoveSemiForCoerce {
|
||||
pub semi: Span,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for RemoveSemiForCoerce {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for RemoveSemiForCoerce {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -549,8 +549,8 @@ pub enum CastUnknownPointerSub {
|
||||
From(Span),
|
||||
}
|
||||
|
||||
impl rustc_errors::AddToDiagnostic for CastUnknownPointerSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl rustc_errors::Subdiagnostic for CastUnknownPointerSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
|
@ -26,8 +26,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_errors::{
|
||||
codes::*, pluralize, struct_span_code_err, AddToDiagnostic, Applicability, Diag,
|
||||
ErrorGuaranteed, StashKey,
|
||||
codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, StashKey,
|
||||
Subdiagnostic,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
@ -2600,7 +2600,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// We know by construction that `<expr>.await` is either on Rust 2015
|
||||
// or results in `ExprKind::Await`. Suggest switching the edition to 2018.
|
||||
err.note("to `.await` a `Future`, switch to Rust 2018 or later");
|
||||
HelpUseLatestEdition::new().add_to_diagnostic(&mut err);
|
||||
HelpUseLatestEdition::new().add_to_diag(&mut err);
|
||||
}
|
||||
|
||||
err.emit()
|
||||
|
@ -1,7 +1,7 @@
|
||||
use hir::GenericParamKind;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagMessage, DiagStyledString,
|
||||
EmissionGuarantee, IntoDiagArg, MultiSpan, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagMessage, DiagStyledString, EmissionGuarantee, IntoDiagArg,
|
||||
MultiSpan, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::FnRetTy;
|
||||
@ -224,8 +224,8 @@ pub enum RegionOriginNote<'a> {
|
||||
},
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for RegionOriginNote<'_> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for RegionOriginNote<'_> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -289,8 +289,8 @@ pub enum LifetimeMismatchLabels {
|
||||
},
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for LifetimeMismatchLabels {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for LifetimeMismatchLabels {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -337,8 +337,8 @@ pub struct AddLifetimeParamsSuggestion<'a> {
|
||||
pub add_note: bool,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -439,8 +439,8 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
|
||||
pub binding_span: Span,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
mut self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -758,8 +758,8 @@ pub struct ConsiderBorrowingParamHelp {
|
||||
pub spans: Vec<Span>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for ConsiderBorrowingParamHelp {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for ConsiderBorrowingParamHelp {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -803,8 +803,8 @@ pub struct DynTraitConstraintSuggestion {
|
||||
pub ident: Ident,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for DynTraitConstraintSuggestion {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for DynTraitConstraintSuggestion {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -850,8 +850,8 @@ pub struct ReqIntroducedLocations {
|
||||
pub add_label: bool,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for ReqIntroducedLocations {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for ReqIntroducedLocations {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
mut self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -873,8 +873,8 @@ pub struct MoreTargeted {
|
||||
pub ident: Symbol,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for MoreTargeted {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for MoreTargeted {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -1296,8 +1296,8 @@ pub struct SuggestTuplePatternMany {
|
||||
pub compatible_variants: Vec<String>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for SuggestTuplePatternMany {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for SuggestTuplePatternMany {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::fluent_generated as fluent;
|
||||
use crate::infer::error_reporting::nice_region_error::find_anon_type;
|
||||
use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp};
|
||||
use rustc_errors::{Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp, Subdiagnostic};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_span::{symbol::kw, Span};
|
||||
|
||||
@ -159,8 +159,8 @@ impl RegionExplanation<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for RegionExplanation<'_> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for RegionExplanation<'_> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
|
@ -11,7 +11,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::SubregionOrigin;
|
||||
use crate::infer::TyCtxt;
|
||||
|
||||
use rustc_errors::AddToDiagnostic;
|
||||
use rustc_errors::Subdiagnostic;
|
||||
use rustc_errors::{Diag, ErrorGuaranteed};
|
||||
use rustc_hir::Ty;
|
||||
use rustc_middle::ty::Region;
|
||||
@ -145,5 +145,5 @@ pub fn suggest_adding_lifetime_params<'tcx>(
|
||||
err: &mut Diag<'_>,
|
||||
) {
|
||||
let suggestion = AddLifetimeParamsSuggestion { tcx, sub, ty_sup, ty_sub, add_note: false };
|
||||
suggestion.add_to_diagnostic(err);
|
||||
suggestion.add_to_diag(err);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::{SubregionOrigin, TypeTrace};
|
||||
use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_errors::{AddToDiagnostic, Applicability, Diag, ErrorGuaranteed, MultiSpan};
|
||||
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, Subdiagnostic};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{walk_ty, Visitor};
|
||||
use rustc_hir::{
|
||||
@ -234,7 +234,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
if let (Some(ident), true) = (override_error_code, fn_returns.is_empty()) {
|
||||
// Provide a more targeted error code and description.
|
||||
let retarget_subdiag = MoreTargeted { ident };
|
||||
retarget_subdiag.add_to_diagnostic(&mut err);
|
||||
retarget_subdiag.add_to_diag(&mut err);
|
||||
}
|
||||
|
||||
let arg = match param.param.pat.simple_ident() {
|
||||
@ -532,7 +532,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
hir_v.visit_ty(self_ty);
|
||||
for &span in &traits {
|
||||
let subdiag = DynTraitConstraintSuggestion { span, ident };
|
||||
subdiag.add_to_diagnostic(err);
|
||||
subdiag.add_to_diag(err);
|
||||
suggested = true;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use crate::errors::{
|
||||
use crate::fluent_generated as fluent;
|
||||
use crate::infer::error_reporting::{note_and_explain_region, TypeErrCtxt};
|
||||
use crate::infer::{self, SubregionOrigin};
|
||||
use rustc_errors::{AddToDiagnostic, Diag};
|
||||
use rustc_errors::{Diag, Subdiagnostic};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::traits::ObligationCauseCode;
|
||||
use rustc_middle::ty::error::TypeError;
|
||||
@ -22,13 +22,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
requirement: ObligationCauseAsDiagArg(trace.cause.clone()),
|
||||
expected_found: self.values_str(trace.values).map(|(e, f, _)| (e, f)),
|
||||
}
|
||||
.add_to_diagnostic(err),
|
||||
.add_to_diag(err),
|
||||
infer::Reborrow(span) => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_reborrow }.add_to_diagnostic(err)
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_reborrow }.add_to_diag(err)
|
||||
}
|
||||
infer::RelateObjectBound(span) => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_relate_object_bound }
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
infer::ReferenceOutlivesReferent(ty, span) => {
|
||||
RegionOriginNote::WithName {
|
||||
@ -37,7 +37,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
name: &self.ty_to_string(ty),
|
||||
continues: false,
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
infer::RelateParamBound(span, ty, opt_span) => {
|
||||
RegionOriginNote::WithName {
|
||||
@ -46,19 +46,19 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
name: &self.ty_to_string(ty),
|
||||
continues: opt_span.is_some(),
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
if let Some(span) = opt_span {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_relate_param_bound_2 }
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
}
|
||||
infer::RelateRegionParamBound(span) => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_relate_region_param_bound }
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
infer::CompareImplItemObligation { span, .. } => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_compare_impl_item_obligation }
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
infer::CheckAssociatedTypeBounds { ref parent, .. } => {
|
||||
self.note_region_origin(err, parent);
|
||||
@ -68,7 +68,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
span,
|
||||
msg: fluent::infer_ascribe_user_type_prove_predicate,
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ lint_deprecated_lint_name =
|
||||
.help = change it to {$replace}
|
||||
|
||||
lint_diag_out_of_impl =
|
||||
diagnostics should only be created in `Diagnostic`/`AddToDiagnostic` impls
|
||||
diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls
|
||||
|
||||
lint_drop_glue =
|
||||
types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{codes::*, AddToDiagnostic, Diag, EmissionGuarantee, SubdiagMessageOp};
|
||||
use rustc_errors::{codes::*, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_session::lint::Level;
|
||||
use rustc_span::{Span, Symbol};
|
||||
@ -23,8 +23,8 @@ pub enum OverruledAttributeSub {
|
||||
CommandLineSource,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for OverruledAttributeSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for OverruledAttributeSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
|
@ -351,7 +351,7 @@ declare_tool_lint! {
|
||||
|
||||
declare_tool_lint! {
|
||||
/// The `diagnostic_outside_of_impl` lint detects calls to functions annotated with
|
||||
/// `#[rustc_lint_diagnostics]` that are outside an `Diagnostic`, `AddToDiagnostic`, or
|
||||
/// `#[rustc_lint_diagnostics]` that are outside an `Diagnostic`, `Subdiagnostic`, or
|
||||
/// `DecorateLint` impl, or a `#[derive(Diagnostic)]`, `#[derive(Subdiagnostic)]`,
|
||||
/// `#[derive(DecorateLint)]` expansion.
|
||||
///
|
||||
@ -359,7 +359,7 @@ declare_tool_lint! {
|
||||
/// [here](https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html).
|
||||
pub rustc::DIAGNOSTIC_OUTSIDE_OF_IMPL,
|
||||
Deny,
|
||||
"prevent creation of diagnostics outside of `Diagnostic`/`AddToDiagnostic` impls",
|
||||
"prevent creation of diagnostics outside of `Diagnostic`/`Subdiagnostic` impls",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ impl LateLintPass<'_> for Diagnostics {
|
||||
}
|
||||
|
||||
// Calls to `#[rustc_lint_diagnostics]`-marked functions should only occur:
|
||||
// - inside an impl of `Diagnostic`, `AddToDiagnostic`, or `DecorateLint`, or
|
||||
// - inside an impl of `Diagnostic`, `Subdiagnostic`, or `DecorateLint`, or
|
||||
// - inside a parent function that is itself marked with `#[rustc_lint_diagnostics]`.
|
||||
//
|
||||
// Otherwise, emit a `DIAGNOSTIC_OUTSIDE_OF_IMPL` lint.
|
||||
@ -467,7 +467,7 @@ impl LateLintPass<'_> for Diagnostics {
|
||||
&& let Impl { of_trait: Some(of_trait), .. } = impl_
|
||||
&& let Some(def_id) = of_trait.trait_def_id()
|
||||
&& let Some(name) = cx.tcx.get_diagnostic_name(def_id)
|
||||
&& matches!(name, sym::Diagnostic | sym::AddToDiagnostic | sym::DecorateLint)
|
||||
&& matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::DecorateLint)
|
||||
{
|
||||
is_inside_appropriate_impl = true;
|
||||
break;
|
||||
|
@ -5,8 +5,8 @@ use std::num::NonZero;
|
||||
use crate::errors::RequestedLevel;
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, DecorateLint, Diag, DiagMessage, DiagStyledString,
|
||||
EmissionGuarantee, SubdiagMessageOp, SuggestionStyle,
|
||||
codes::*, Applicability, DecorateLint, Diag, DiagMessage, DiagStyledString, EmissionGuarantee,
|
||||
SubdiagMessageOp, Subdiagnostic, SuggestionStyle,
|
||||
};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
||||
@ -270,8 +270,8 @@ pub struct SuggestChangingAssocTypes<'a, 'b> {
|
||||
pub ty: &'a rustc_hir::Ty<'b>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> AddToDiagnostic for SuggestChangingAssocTypes<'a, 'b> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl<'a, 'b> Subdiagnostic for SuggestChangingAssocTypes<'a, 'b> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -326,8 +326,8 @@ pub struct BuiltinTypeAliasGenericBoundsSuggestion {
|
||||
pub suggestions: Vec<(Span, String)>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for BuiltinTypeAliasGenericBoundsSuggestion {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for BuiltinTypeAliasGenericBoundsSuggestion {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -434,7 +434,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
||||
fluent::lint_builtin_unpermitted_type_init_label_suggestion,
|
||||
);
|
||||
}
|
||||
self.sub.add_to_diagnostic(diag);
|
||||
self.sub.add_to_diag(diag);
|
||||
}
|
||||
|
||||
fn msg(&self) -> DiagMessage {
|
||||
@ -447,8 +447,8 @@ pub struct BuiltinUnpermittedTypeInitSub {
|
||||
pub err: InitError,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for BuiltinUnpermittedTypeInitSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for BuiltinUnpermittedTypeInitSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -502,8 +502,8 @@ pub struct BuiltinClashingExternSub<'a> {
|
||||
pub found: Ty<'a>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for BuiltinClashingExternSub<'_> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for BuiltinClashingExternSub<'_> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -784,8 +784,8 @@ pub struct HiddenUnicodeCodepointsDiagLabels {
|
||||
pub spans: Vec<(char, Span)>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagLabels {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for HiddenUnicodeCodepointsDiagLabels {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -802,8 +802,8 @@ pub enum HiddenUnicodeCodepointsDiagSub {
|
||||
}
|
||||
|
||||
// Used because of multiple multipart_suggestion and note
|
||||
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for HiddenUnicodeCodepointsDiagSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -950,8 +950,8 @@ pub struct NonBindingLetSub {
|
||||
pub is_assign_desugar: bool,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for NonBindingLetSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for NonBindingLetSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -1236,8 +1236,8 @@ pub enum NonSnakeCaseDiagSub {
|
||||
SuggestionAndNote { span: Span },
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for NonSnakeCaseDiagSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for NonSnakeCaseDiagSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -1478,8 +1478,8 @@ pub enum OverflowingBinHexSign {
|
||||
Negative,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for OverflowingBinHexSign {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for OverflowingBinHexSign {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
|
@ -16,7 +16,7 @@ use synstructure::{BindingInfo, Structure, VariantInfo};
|
||||
|
||||
use super::utils::SubdiagnosticVariant;
|
||||
|
||||
/// The central struct for constructing the `add_to_diagnostic` method from an annotated struct.
|
||||
/// The central struct for constructing the `add_to_diag` method from an annotated struct.
|
||||
pub(crate) struct SubdiagnosticDeriveBuilder {
|
||||
diag: syn::Ident,
|
||||
f: syn::Ident,
|
||||
@ -86,8 +86,8 @@ impl SubdiagnosticDeriveBuilder {
|
||||
let diag = &self.diag;
|
||||
let f = &self.f;
|
||||
let ret = structure.gen_impl(quote! {
|
||||
gen impl rustc_errors::AddToDiagnostic for @Self {
|
||||
fn add_to_diagnostic_with<__G, __F>(
|
||||
gen impl rustc_errors::Subdiagnostic for @Self {
|
||||
fn add_to_diag_with<__G, __F>(
|
||||
self,
|
||||
#diag: &mut rustc_errors::Diag<'_, __G>,
|
||||
#f: __F
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::DiagArgValue;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level,
|
||||
MultiSpan, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level, MultiSpan,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
@ -419,8 +419,8 @@ pub struct UnsafeNotInheritedLintNote {
|
||||
pub body_span: Span,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for UnsafeNotInheritedLintNote {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for UnsafeNotInheritedLintNote {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -865,8 +865,8 @@ pub struct Variant {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl<'tcx> AddToDiagnostic for AdtDefinedHere<'tcx> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl<'tcx> Subdiagnostic for AdtDefinedHere<'tcx> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
|
@ -3,8 +3,8 @@ use std::borrow::Cow;
|
||||
use rustc_ast::token::Token;
|
||||
use rustc_ast::{Path, Visibility};
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level,
|
||||
SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_session::errors::ExprParenthesesNeeded;
|
||||
@ -1093,17 +1093,17 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedIdentifier {
|
||||
diag.arg("token", self.token);
|
||||
|
||||
if let Some(sugg) = self.suggest_raw {
|
||||
sugg.add_to_diagnostic(&mut diag);
|
||||
sugg.add_to_diag(&mut diag);
|
||||
}
|
||||
|
||||
ExpectedIdentifierFound::new(token_descr, self.span).add_to_diagnostic(&mut diag);
|
||||
ExpectedIdentifierFound::new(token_descr, self.span).add_to_diag(&mut diag);
|
||||
|
||||
if let Some(sugg) = self.suggest_remove_comma {
|
||||
sugg.add_to_diagnostic(&mut diag);
|
||||
sugg.add_to_diag(&mut diag);
|
||||
}
|
||||
|
||||
if let Some(help) = self.help_cannot_start_number {
|
||||
help.add_to_diagnostic(&mut diag);
|
||||
help.add_to_diag(&mut diag);
|
||||
}
|
||||
|
||||
diag
|
||||
@ -1154,7 +1154,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedSemi {
|
||||
diag.span_label(unexpected_token_label, fluent::parse_label_unexpected_token);
|
||||
}
|
||||
|
||||
self.sugg.add_to_diagnostic(&mut diag);
|
||||
self.sugg.add_to_diag(&mut diag);
|
||||
|
||||
diag
|
||||
}
|
||||
@ -1466,8 +1466,8 @@ pub(crate) struct FnTraitMissingParen {
|
||||
pub machine_applicable: bool,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for FnTraitMissingParen {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for FnTraitMissingParen {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
|
@ -36,8 +36,8 @@ use rustc_ast::{
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{
|
||||
pluralize, AddToDiagnostic, Applicability, Diag, DiagCtxt, ErrorGuaranteed, FatalError, PErr,
|
||||
PResult,
|
||||
pluralize, Applicability, Diag, DiagCtxt, ErrorGuaranteed, FatalError, PErr, PResult,
|
||||
Subdiagnostic,
|
||||
};
|
||||
use rustc_session::errors::ExprParenthesesNeeded;
|
||||
use rustc_span::source_map::Spanned;
|
||||
@ -1271,7 +1271,7 @@ impl<'a> Parser<'a> {
|
||||
Ok(_) => {
|
||||
if self.token == token::Eq {
|
||||
let sugg = SuggAddMissingLetStmt { span: prev_span };
|
||||
sugg.add_to_diagnostic(err);
|
||||
sugg.add_to_diag(err);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
|
@ -27,7 +27,7 @@ use rustc_ast::{Arm, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLim
|
||||
use rustc_ast::{ClosureBinder, MetaItemLit, StmtKind};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{AddToDiagnostic, Applicability, Diag, PResult, StashKey};
|
||||
use rustc_errors::{Applicability, Diag, PResult, StashKey, Subdiagnostic};
|
||||
use rustc_lexer::unescape::unescape_char;
|
||||
use rustc_macros::Subdiagnostic;
|
||||
use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded};
|
||||
@ -3451,8 +3451,8 @@ impl<'a> Parser<'a> {
|
||||
let in_if_guard = self.restrictions.contains(Restrictions::IN_IF_GUARD);
|
||||
|
||||
let async_block_err = |e: &mut Diag<'_>, span: Span| {
|
||||
errors::AsyncBlockIn2015 { span }.add_to_diagnostic(e);
|
||||
errors::HelpUseLatestEdition::new().add_to_diagnostic(e);
|
||||
errors::AsyncBlockIn2015 { span }.add_to_diag(e);
|
||||
errors::HelpUseLatestEdition::new().add_to_diag(e);
|
||||
};
|
||||
|
||||
while self.token != token::CloseDelim(close_delim) {
|
||||
|
@ -6,8 +6,8 @@ use std::{
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_ast::Label;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, DiagSymbolList, Diagnostic,
|
||||
EmissionGuarantee, Level, MultiSpan, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagCtxt, DiagSymbolList, Diagnostic, EmissionGuarantee, Level,
|
||||
MultiSpan, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_hir::{self as hir, ExprKind, Target};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
@ -1751,8 +1751,8 @@ pub struct UnusedVariableStringInterp {
|
||||
pub hi: Span,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for UnusedVariableStringInterp {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for UnusedVariableStringInterp {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, SubdiagMessageOp};
|
||||
use rustc_errors::{Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
|
||||
use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::thir::Pat;
|
||||
use rustc_middle::ty::Ty;
|
||||
@ -61,8 +61,8 @@ pub struct Overlap<'tcx> {
|
||||
pub range: Pat<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> AddToDiagnostic for Overlap<'tcx> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl<'tcx> Subdiagnostic for Overlap<'tcx> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
@ -109,8 +109,8 @@ pub struct GappedRange<'tcx> {
|
||||
pub first_range: Pat<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> AddToDiagnostic for GappedRange<'tcx> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl<'tcx> Subdiagnostic for GappedRange<'tcx> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
|
@ -129,7 +129,6 @@ symbols! {
|
||||
Abi,
|
||||
AcqRel,
|
||||
Acquire,
|
||||
AddToDiagnostic,
|
||||
Any,
|
||||
Arc,
|
||||
ArcWeak,
|
||||
@ -305,6 +304,7 @@ symbols! {
|
||||
String,
|
||||
StructuralPartialEq,
|
||||
SubdiagMessage,
|
||||
Subdiagnostic,
|
||||
Sync,
|
||||
T,
|
||||
Target,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level,
|
||||
SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_middle::ty::{self, ClosureKind, PolyTraitRef, Ty};
|
||||
@ -100,8 +100,8 @@ pub enum AdjustSignatureBorrow {
|
||||
RemoveBorrow { remove_borrow: Vec<(Span, String)> },
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for AdjustSignatureBorrow {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for AdjustSignatureBorrow {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
|
@ -14,8 +14,8 @@ extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
|
||||
use rustc_errors::{
|
||||
AddToDiagnostic, DecorateLint, Diag, DiagCtxt, DiagInner, DiagMessage, EmissionGuarantee,
|
||||
Diagnostic, Level, SubdiagMessageOp,
|
||||
DecorateLint, Diag, DiagCtxt, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::Span;
|
||||
@ -53,10 +53,10 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for TranslatableInDiagnostic {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UntranslatableInAddToDiagnostic;
|
||||
pub struct UntranslatableInAddtoDiag;
|
||||
|
||||
impl AddToDiagnostic for UntranslatableInAddToDiagnostic {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for UntranslatableInAddtoDiag {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -66,10 +66,10 @@ impl AddToDiagnostic for UntranslatableInAddToDiagnostic {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TranslatableInAddToDiagnostic;
|
||||
pub struct TranslatableInAddtoDiag;
|
||||
|
||||
impl AddToDiagnostic for TranslatableInAddToDiagnostic {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for TranslatableInAddtoDiag {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -105,10 +105,10 @@ impl<'a> DecorateLint<'a, ()> for TranslatableInDecorateLint {
|
||||
|
||||
pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) {
|
||||
let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`AddToDiagnostic` impls
|
||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls
|
||||
|
||||
let _diag = dcx.struct_err("untranslatable diagnostic");
|
||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`AddToDiagnostic` impls
|
||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls
|
||||
//~^^ ERROR diagnostics should be created using translatable messages
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ error: diagnostics should be created using translatable messages
|
||||
LL | diag.note("untranslatable diagnostic");
|
||||
| ^^^^
|
||||
|
||||
error: diagnostics should only be created in `Diagnostic`/`AddToDiagnostic` impls
|
||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls
|
||||
--> $DIR/diagnostics.rs:107:21
|
||||
|
|
||||
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
||||
@ -34,7 +34,7 @@ note: the lint level is defined here
|
||||
LL | #![deny(rustc::diagnostic_outside_of_impl)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should only be created in `Diagnostic`/`AddToDiagnostic` impls
|
||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls
|
||||
--> $DIR/diagnostics.rs:110:21
|
||||
|
|
||||
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
||||
|
Loading…
Reference in New Issue
Block a user