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:
bors 2022-10-23 09:06:39 +00:00
commit e64f1110c0
67 changed files with 1666 additions and 1694 deletions

View file

@ -7,7 +7,7 @@ use rustc_middle::ty::Ty;
use rustc_span::{symbol::Ident, Span, Symbol};
#[derive(Diagnostic)]
#[diag(hir_analysis::unrecognized_atomic_operation, code = "E0092")]
#[diag(hir_analysis_unrecognized_atomic_operation, code = "E0092")]
pub struct UnrecognizedAtomicOperation<'a> {
#[primary_span]
#[label]
@ -16,7 +16,7 @@ pub struct UnrecognizedAtomicOperation<'a> {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::wrong_number_of_generic_arguments_to_intrinsic, code = "E0094")]
#[diag(hir_analysis_wrong_number_of_generic_arguments_to_intrinsic, code = "E0094")]
pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
#[primary_span]
#[label]
@ -27,7 +27,7 @@ pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::unrecognized_intrinsic_function, code = "E0093")]
#[diag(hir_analysis_unrecognized_intrinsic_function, code = "E0093")]
pub struct UnrecognizedIntrinsicFunction {
#[primary_span]
#[label]
@ -36,19 +36,19 @@ pub struct UnrecognizedIntrinsicFunction {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::lifetimes_or_bounds_mismatch_on_trait, code = "E0195")]
#[diag(hir_analysis_lifetimes_or_bounds_mismatch_on_trait, code = "E0195")]
pub struct LifetimesOrBoundsMismatchOnTrait {
#[primary_span]
#[label]
pub span: Span,
#[label(hir_analysis::generics_label)]
#[label(generics_label)]
pub generics_span: Option<Span>,
pub item_kind: &'static str,
pub ident: Ident,
}
#[derive(Diagnostic)]
#[diag(hir_analysis::drop_impl_on_wrong_item, code = "E0120")]
#[diag(hir_analysis_drop_impl_on_wrong_item, code = "E0120")]
pub struct DropImplOnWrongItem {
#[primary_span]
#[label]
@ -56,18 +56,18 @@ pub struct DropImplOnWrongItem {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::field_already_declared, code = "E0124")]
#[diag(hir_analysis_field_already_declared, code = "E0124")]
pub struct FieldAlreadyDeclared {
pub field_name: Ident,
#[primary_span]
#[label]
pub span: Span,
#[label(hir_analysis::previous_decl_label)]
#[label(previous_decl_label)]
pub prev_span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_analysis::copy_impl_on_type_with_dtor, code = "E0184")]
#[diag(hir_analysis_copy_impl_on_type_with_dtor, code = "E0184")]
pub struct CopyImplOnTypeWithDtor {
#[primary_span]
#[label]
@ -75,14 +75,14 @@ pub struct CopyImplOnTypeWithDtor {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::multiple_relaxed_default_bounds, code = "E0203")]
#[diag(hir_analysis_multiple_relaxed_default_bounds, code = "E0203")]
pub struct MultipleRelaxedDefaultBounds {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_analysis::copy_impl_on_non_adt, code = "E0206")]
#[diag(hir_analysis_copy_impl_on_non_adt, code = "E0206")]
pub struct CopyImplOnNonAdt {
#[primary_span]
#[label]
@ -90,23 +90,23 @@ pub struct CopyImplOnNonAdt {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::trait_object_declared_with_no_traits, code = "E0224")]
#[diag(hir_analysis_trait_object_declared_with_no_traits, code = "E0224")]
pub struct TraitObjectDeclaredWithNoTraits {
#[primary_span]
pub span: Span,
#[label(hir_analysis::alias_span)]
#[label(alias_span)]
pub trait_alias_span: Option<Span>,
}
#[derive(Diagnostic)]
#[diag(hir_analysis::ambiguous_lifetime_bound, code = "E0227")]
#[diag(hir_analysis_ambiguous_lifetime_bound, code = "E0227")]
pub struct AmbiguousLifetimeBound {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_analysis::assoc_type_binding_not_allowed, code = "E0229")]
#[diag(hir_analysis_assoc_type_binding_not_allowed, code = "E0229")]
pub struct AssocTypeBindingNotAllowed {
#[primary_span]
#[label]
@ -114,7 +114,7 @@ pub struct AssocTypeBindingNotAllowed {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::typeof_reserved_keyword_used, code = "E0516")]
#[diag(hir_analysis_typeof_reserved_keyword_used, code = "E0516")]
pub struct TypeofReservedKeywordUsed<'tcx> {
pub ty: Ty<'tcx>,
#[primary_span]
@ -125,19 +125,19 @@ pub struct TypeofReservedKeywordUsed<'tcx> {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::value_of_associated_struct_already_specified, code = "E0719")]
#[diag(hir_analysis_value_of_associated_struct_already_specified, code = "E0719")]
pub struct ValueOfAssociatedStructAlreadySpecified {
#[primary_span]
#[label]
pub span: Span,
#[label(hir_analysis::previous_bound_label)]
#[label(previous_bound_label)]
pub prev_span: Span,
pub item_name: Ident,
pub def_path: String,
}
#[derive(Diagnostic)]
#[diag(hir_analysis::unconstrained_opaque_type)]
#[diag(hir_analysis_unconstrained_opaque_type)]
#[note]
pub struct UnconstrainedOpaqueType {
#[primary_span]
@ -158,7 +158,7 @@ impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut err = handler.struct_span_err_with_code(
self.span,
rustc_errors::fluent::hir_analysis::missing_type_params,
rustc_errors::fluent::hir_analysis_missing_type_params,
error_code!(E0393),
);
err.set_arg("parameterCount", self.missing_type_params.len());
@ -171,7 +171,7 @@ impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
.join(", "),
);
err.span_label(self.def_span, rustc_errors::fluent::hir_analysis::label);
err.span_label(self.def_span, rustc_errors::fluent::label);
let mut suggested = false;
// Don't suggest setting the type params if there are some already: the order is
@ -186,7 +186,7 @@ impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
// least we can clue them to the correct syntax `Iterator<Type>`.
err.span_suggestion(
self.span,
rustc_errors::fluent::hir_analysis::suggestion,
rustc_errors::fluent::suggestion,
format!(
"{}<{}>",
snippet,
@ -202,16 +202,16 @@ impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
}
}
if !suggested {
err.span_label(self.span, rustc_errors::fluent::hir_analysis::no_suggestion_label);
err.span_label(self.span, rustc_errors::fluent::no_suggestion_label);
}
err.note(rustc_errors::fluent::hir_analysis::note);
err.note(rustc_errors::fluent::note);
err
}
}
#[derive(Diagnostic)]
#[diag(hir_analysis::manual_implementation, code = "E0183")]
#[diag(hir_analysis_manual_implementation, code = "E0183")]
#[help]
pub struct ManualImplementation {
#[primary_span]
@ -221,21 +221,21 @@ pub struct ManualImplementation {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::substs_on_overridden_impl)]
#[diag(hir_analysis_substs_on_overridden_impl)]
pub struct SubstsOnOverriddenImpl {
#[primary_span]
pub span: Span,
}
#[derive(LintDiagnostic)]
#[diag(hir_analysis::unused_extern_crate)]
#[diag(hir_analysis_unused_extern_crate)]
pub struct UnusedExternCrate {
#[suggestion(applicability = "machine-applicable", code = "")]
pub span: Span,
}
#[derive(LintDiagnostic)]
#[diag(hir_analysis::extern_crate_not_idiomatic)]
#[diag(hir_analysis_extern_crate_not_idiomatic)]
pub struct ExternCrateNotIdiomatic {
#[suggestion_short(applicability = "machine-applicable", code = "{suggestion_code}")]
pub span: Span,
@ -244,7 +244,7 @@ pub struct ExternCrateNotIdiomatic {
}
#[derive(Diagnostic)]
#[diag(hir_analysis::expected_used_symbol)]
#[diag(hir_analysis_expected_used_symbol)]
pub struct ExpectedUsedSymbol {
#[primary_span]
pub span: Span,