Auto merge of #103345 - Nilstrieb:diag-flat, r=compiler-errors
Flatten diagnostic slug modules This makes it easier to grep for the slugs in the code. See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Localization.20infra.20interferes.20with.20grepping.20for.20error for more discussion about it. This was mostly done with a few regexes and a bunch of manual work. This also exposes a pretty annoying inconsistency for the extra labels. Some of the extra labels are defined as additional properties in the fluent message (which makes them not prefixed with the crate name) and some of them are new fluent messages themselves (which makes them prefixed with the crate name). I don't know whether we want to clean this up at some point but it's useful to know. r? `@davidtwco`
This commit is contained in:
commit
e64f1110c0
67 changed files with 1666 additions and 1694 deletions
|
@ -18,19 +18,19 @@ use crate::infer::error_reporting::{
|
|||
pub mod note_and_explain;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(infer::opaque_hidden_type)]
|
||||
#[diag(infer_opaque_hidden_type)]
|
||||
pub struct OpaqueHiddenTypeDiag {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
#[note(infer::opaque_type)]
|
||||
#[note(opaque_type)]
|
||||
pub opaque_type: Span,
|
||||
#[note(infer::hidden_type)]
|
||||
#[note(hidden_type)]
|
||||
pub hidden_type: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(infer::type_annotations_needed, code = "E0282")]
|
||||
#[diag(infer_type_annotations_needed, code = "E0282")]
|
||||
pub struct AnnotationRequired<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
|
@ -48,7 +48,7 @@ pub struct AnnotationRequired<'a> {
|
|||
|
||||
// Copy of `AnnotationRequired` for E0283
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(infer::type_annotations_needed, code = "E0283")]
|
||||
#[diag(infer_type_annotations_needed, code = "E0283")]
|
||||
pub struct AmbigousImpl<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
|
@ -66,7 +66,7 @@ pub struct AmbigousImpl<'a> {
|
|||
|
||||
// Copy of `AnnotationRequired` for E0284
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(infer::type_annotations_needed, code = "E0284")]
|
||||
#[diag(infer_type_annotations_needed, code = "E0284")]
|
||||
pub struct AmbigousReturn<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
|
@ -83,7 +83,7 @@ pub struct AmbigousReturn<'a> {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(infer::need_type_info_in_generator, code = "E0698")]
|
||||
#[diag(infer_need_type_info_in_generator, code = "E0698")]
|
||||
pub struct NeedTypeInfoInGenerator<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
|
@ -94,7 +94,7 @@ pub struct NeedTypeInfoInGenerator<'a> {
|
|||
|
||||
// Used when a better one isn't available
|
||||
#[derive(Subdiagnostic)]
|
||||
#[label(infer::label_bad)]
|
||||
#[label(infer_label_bad)]
|
||||
pub struct InferenceBadError<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
|
@ -110,7 +110,7 @@ pub struct InferenceBadError<'a> {
|
|||
#[derive(Subdiagnostic)]
|
||||
pub enum SourceKindSubdiag<'a> {
|
||||
#[suggestion_verbose(
|
||||
infer::source_kind_subdiag_let,
|
||||
infer_source_kind_subdiag_let,
|
||||
code = ": {type_name}",
|
||||
applicability = "has-placeholders"
|
||||
)]
|
||||
|
@ -125,7 +125,7 @@ pub enum SourceKindSubdiag<'a> {
|
|||
prefix: &'a str,
|
||||
arg_name: String,
|
||||
},
|
||||
#[label(infer::source_kind_subdiag_generic_label)]
|
||||
#[label(infer_source_kind_subdiag_generic_label)]
|
||||
GenericLabel {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
|
@ -136,7 +136,7 @@ pub enum SourceKindSubdiag<'a> {
|
|||
parent_name: String,
|
||||
},
|
||||
#[suggestion_verbose(
|
||||
infer::source_kind_subdiag_generic_suggestion,
|
||||
infer_source_kind_subdiag_generic_suggestion,
|
||||
code = "::<{args}>",
|
||||
applicability = "has-placeholders"
|
||||
)]
|
||||
|
@ -151,7 +151,7 @@ pub enum SourceKindSubdiag<'a> {
|
|||
#[derive(Subdiagnostic)]
|
||||
pub enum SourceKindMultiSuggestion<'a> {
|
||||
#[multipart_suggestion_verbose(
|
||||
infer::source_kind_fully_qualified,
|
||||
infer_source_kind_fully_qualified,
|
||||
applicability = "has-placeholders"
|
||||
)]
|
||||
FullyQualified {
|
||||
|
@ -164,7 +164,7 @@ pub enum SourceKindMultiSuggestion<'a> {
|
|||
successor_pos: &'a str,
|
||||
},
|
||||
#[multipart_suggestion_verbose(
|
||||
infer::source_kind_closure_return,
|
||||
infer_source_kind_closure_return,
|
||||
applicability = "has-placeholders"
|
||||
)]
|
||||
ClosureReturn {
|
||||
|
@ -260,7 +260,7 @@ impl AddToDiagnostic for RegionOriginNote<'_> {
|
|||
requirement,
|
||||
expected_found: Some((expected, found)),
|
||||
} => {
|
||||
label_or_note(span, fluent::infer::subtype);
|
||||
label_or_note(span, fluent::infer_subtype);
|
||||
diag.set_arg("requirement", requirement);
|
||||
|
||||
diag.note_expected_found(&"", expected, &"", found);
|
||||
|
@ -269,7 +269,7 @@ impl AddToDiagnostic for RegionOriginNote<'_> {
|
|||
// FIXME: this really should be handled at some earlier stage. Our
|
||||
// handling of region checking when type errors are present is
|
||||
// *terrible*.
|
||||
label_or_note(span, fluent::infer::subtype_2);
|
||||
label_or_note(span, fluent::infer_subtype_2);
|
||||
diag.set_arg("requirement", requirement);
|
||||
}
|
||||
};
|
||||
|
@ -300,9 +300,9 @@ impl AddToDiagnostic for LifetimeMismatchLabels {
|
|||
{
|
||||
match self {
|
||||
LifetimeMismatchLabels::InRet { param_span, ret_span, span, label_var1 } => {
|
||||
diag.span_label(param_span, fluent::infer::declared_different);
|
||||
diag.span_label(ret_span, fluent::infer::nothing);
|
||||
diag.span_label(span, fluent::infer::data_returned);
|
||||
diag.span_label(param_span, fluent::infer_declared_different);
|
||||
diag.span_label(ret_span, fluent::infer_nothing);
|
||||
diag.span_label(span, fluent::infer_data_returned);
|
||||
diag.set_arg("label_var1_exists", label_var1.is_some());
|
||||
diag.set_arg("label_var1", label_var1.map(|x| x.to_string()).unwrap_or_default());
|
||||
}
|
||||
|
@ -315,13 +315,13 @@ impl AddToDiagnostic for LifetimeMismatchLabels {
|
|||
sub: label_var2,
|
||||
} => {
|
||||
if hir_equal {
|
||||
diag.span_label(ty_sup, fluent::infer::declared_multiple);
|
||||
diag.span_label(ty_sub, fluent::infer::nothing);
|
||||
diag.span_label(span, fluent::infer::data_lifetime_flow);
|
||||
diag.span_label(ty_sup, fluent::infer_declared_multiple);
|
||||
diag.span_label(ty_sub, fluent::infer_nothing);
|
||||
diag.span_label(span, fluent::infer_data_lifetime_flow);
|
||||
} else {
|
||||
diag.span_label(ty_sup, fluent::infer::types_declared_different);
|
||||
diag.span_label(ty_sub, fluent::infer::nothing);
|
||||
diag.span_label(span, fluent::infer::data_flows);
|
||||
diag.span_label(ty_sup, fluent::infer_types_declared_different);
|
||||
diag.span_label(ty_sub, fluent::infer_nothing);
|
||||
diag.span_label(span, fluent::infer_data_flows);
|
||||
diag.set_arg("label_var1_exists", label_var1.is_some());
|
||||
diag.set_arg(
|
||||
"label_var1",
|
||||
|
@ -419,7 +419,7 @@ impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
|
|||
}
|
||||
|
||||
diag.multipart_suggestion(
|
||||
fluent::infer::lifetime_param_suggestion,
|
||||
fluent::infer_lifetime_param_suggestion,
|
||||
suggestions,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
@ -427,13 +427,13 @@ impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
|
|||
true
|
||||
};
|
||||
if mk_suggestion() && self.add_note {
|
||||
diag.note(fluent::infer::lifetime_param_suggestion_elided);
|
||||
diag.note(fluent::infer_lifetime_param_suggestion_elided);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(infer::lifetime_mismatch, code = "E0623")]
|
||||
#[diag(infer_lifetime_mismatch, code = "E0623")]
|
||||
pub struct LifetimeMismatch<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
|
@ -454,32 +454,32 @@ impl AddToDiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
|
|||
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
|
||||
{
|
||||
self.unmet_requirements
|
||||
.push_span_label(self.binding_span, fluent::infer::msl_introduces_static);
|
||||
diag.span_note(self.unmet_requirements, fluent::infer::msl_unmet_req);
|
||||
.push_span_label(self.binding_span, fluent::infer_msl_introduces_static);
|
||||
diag.span_note(self.unmet_requirements, fluent::infer_msl_unmet_req);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#100717): replace with a `Option<Span>` when subdiagnostic supports that
|
||||
#[derive(Subdiagnostic)]
|
||||
pub enum DoesNotOutliveStaticFromImpl {
|
||||
#[note(infer::does_not_outlive_static_from_impl)]
|
||||
#[note(infer_does_not_outlive_static_from_impl)]
|
||||
Spanned {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
},
|
||||
#[note(infer::does_not_outlive_static_from_impl)]
|
||||
#[note(infer_does_not_outlive_static_from_impl)]
|
||||
Unspanned,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub enum ImplicitStaticLifetimeSubdiag {
|
||||
#[note(infer::implicit_static_lifetime_note)]
|
||||
#[note(infer_implicit_static_lifetime_note)]
|
||||
Note {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
},
|
||||
#[suggestion_verbose(
|
||||
infer::implicit_static_lifetime_suggestion,
|
||||
infer_implicit_static_lifetime_suggestion,
|
||||
code = " + '_",
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
|
@ -490,7 +490,7 @@ pub enum ImplicitStaticLifetimeSubdiag {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(infer::mismatched_static_lifetime)]
|
||||
#[diag(infer_mismatched_static_lifetime)]
|
||||
pub struct MismatchedStaticLifetime<'a> {
|
||||
#[primary_span]
|
||||
pub cause_span: Span,
|
||||
|
|
|
@ -166,9 +166,9 @@ impl AddToDiagnostic for RegionExplanation<'_> {
|
|||
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
|
||||
{
|
||||
if let Some(span) = self.desc.span {
|
||||
diag.span_note(span, fluent::infer::region_explanation);
|
||||
diag.span_note(span, fluent::infer_region_explanation);
|
||||
} else {
|
||||
diag.note(fluent::infer::region_explanation);
|
||||
diag.note(fluent::infer_region_explanation);
|
||||
}
|
||||
self.desc.add_to(diag);
|
||||
diag.set_arg("pref_kind", self.prefix);
|
||||
|
|
|
@ -19,26 +19,27 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
expected_found: self.values_str(trace.values),
|
||||
}
|
||||
.add_to_diagnostic(err),
|
||||
infer::Reborrow(span) => RegionOriginNote::Plain { span, msg: fluent::infer::reborrow }
|
||||
.add_to_diagnostic(err),
|
||||
infer::Reborrow(span) => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_reborrow }.add_to_diagnostic(err)
|
||||
}
|
||||
infer::ReborrowUpvar(span, ref upvar_id) => {
|
||||
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
|
||||
RegionOriginNote::WithName {
|
||||
span,
|
||||
msg: fluent::infer::reborrow,
|
||||
msg: fluent::infer_reborrow,
|
||||
name: &var_name.to_string(),
|
||||
continues: false,
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
}
|
||||
infer::RelateObjectBound(span) => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer::relate_object_bound }
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_relate_object_bound }
|
||||
.add_to_diagnostic(err);
|
||||
}
|
||||
infer::DataBorrowed(ty, span) => {
|
||||
RegionOriginNote::WithName {
|
||||
span,
|
||||
msg: fluent::infer::data_borrowed,
|
||||
msg: fluent::infer_data_borrowed,
|
||||
name: &self.ty_to_string(ty),
|
||||
continues: false,
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
infer::ReferenceOutlivesReferent(ty, span) => {
|
||||
RegionOriginNote::WithName {
|
||||
span,
|
||||
msg: fluent::infer::reference_outlives_referent,
|
||||
msg: fluent::infer_reference_outlives_referent,
|
||||
name: &self.ty_to_string(ty),
|
||||
continues: false,
|
||||
}
|
||||
|
@ -56,22 +57,22 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
infer::RelateParamBound(span, ty, opt_span) => {
|
||||
RegionOriginNote::WithName {
|
||||
span,
|
||||
msg: fluent::infer::relate_param_bound,
|
||||
msg: fluent::infer_relate_param_bound,
|
||||
name: &self.ty_to_string(ty),
|
||||
continues: opt_span.is_some(),
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
if let Some(span) = opt_span {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer::relate_param_bound_2 }
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_relate_param_bound_2 }
|
||||
.add_to_diagnostic(err);
|
||||
}
|
||||
}
|
||||
infer::RelateRegionParamBound(span) => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer::relate_region_param_bound }
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_relate_region_param_bound }
|
||||
.add_to_diagnostic(err);
|
||||
}
|
||||
infer::CompareImplItemObligation { span, .. } => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer::compare_impl_item_obligation }
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_compare_impl_item_obligation }
|
||||
.add_to_diagnostic(err);
|
||||
}
|
||||
infer::CheckAssociatedTypeBounds { ref parent, .. } => {
|
||||
|
@ -80,7 +81,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
infer::AscribeUserTypeProvePredicate(span) => {
|
||||
RegionOriginNote::Plain {
|
||||
span,
|
||||
msg: fluent::infer::ascribe_user_type_prove_predicate,
|
||||
msg: fluent::infer_ascribe_user_type_prove_predicate,
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue