diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_error_messages/locales/en-US/compiletest.ftl | 5 | ||||
| -rw-r--r-- | compiler/rustc_error_messages/locales/en-US/hir_analysis.ftl (renamed from compiler/rustc_error_messages/locales/en-US/typeck.ftl) | 64 | ||||
| -rw-r--r-- | compiler/rustc_error_messages/src/lib.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/errors.rs | 89 | ||||
| -rw-r--r-- | compiler/rustc_macros/src/diagnostics/diagnostic.rs | 4 |
5 files changed, 92 insertions, 85 deletions
diff --git a/compiler/rustc_error_messages/locales/en-US/compiletest.ftl b/compiler/rustc_error_messages/locales/en-US/compiletest.ftl new file mode 100644 index 00000000000..55061fbce7e --- /dev/null +++ b/compiler/rustc_error_messages/locales/en-US/compiletest.ftl @@ -0,0 +1,5 @@ +compiletest_example = this is an example message used in testing + .note = with a note + .help = with a help + .suggestion = with a suggestion + .label = with a label diff --git a/compiler/rustc_error_messages/locales/en-US/typeck.ftl b/compiler/rustc_error_messages/locales/en-US/hir_analysis.ftl index 272731d9914..c6a4ff6f0e0 100644 --- a/compiler/rustc_error_messages/locales/en-US/typeck.ftl +++ b/compiler/rustc_error_messages/locales/en-US/hir_analysis.ftl @@ -1,101 +1,101 @@ -typeck_field_multiply_specified_in_initializer = +hir_analysis_field_multiply_specified_in_initializer = field `{$ident}` specified more than once .label = used more than once .previous_use_label = first use of `{$ident}` -typeck_unrecognized_atomic_operation = +hir_analysis_unrecognized_atomic_operation = unrecognized atomic operation function: `{$op}` .label = unrecognized atomic operation -typeck_wrong_number_of_generic_arguments_to_intrinsic = +hir_analysis_wrong_number_of_generic_arguments_to_intrinsic = intrinsic has wrong number of {$descr} parameters: found {$found}, expected {$expected} .label = expected {$expected} {$descr} {$expected -> [one] parameter *[other] parameters } -typeck_unrecognized_intrinsic_function = +hir_analysis_unrecognized_intrinsic_function = unrecognized intrinsic function: `{$name}` .label = unrecognized intrinsic -typeck_lifetimes_or_bounds_mismatch_on_trait = +hir_analysis_lifetimes_or_bounds_mismatch_on_trait = lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration .label = lifetimes do not match {$item_kind} in trait .generics_label = lifetimes in impl do not match this {$item_kind} in trait -typeck_drop_impl_on_wrong_item = +hir_analysis_drop_impl_on_wrong_item = the `Drop` trait may only be implemented for local structs, enums, and unions .label = must be a struct, enum, or union in the current crate -typeck_field_already_declared = +hir_analysis_field_already_declared = field `{$field_name}` is already declared .label = field already declared .previous_decl_label = `{$field_name}` first declared here -typeck_copy_impl_on_type_with_dtor = +hir_analysis_copy_impl_on_type_with_dtor = the trait `Copy` may not be implemented for this type; the type has a destructor .label = `Copy` not allowed on types with destructors -typeck_multiple_relaxed_default_bounds = +hir_analysis_multiple_relaxed_default_bounds = type parameter has more than one relaxed default bound, only one is supported -typeck_copy_impl_on_non_adt = +hir_analysis_copy_impl_on_non_adt = the trait `Copy` may not be implemented for this type .label = type is not a structure or enumeration -typeck_trait_object_declared_with_no_traits = +hir_analysis_trait_object_declared_with_no_traits = at least one trait is required for an object type .alias_span = this alias does not contain a trait -typeck_ambiguous_lifetime_bound = +hir_analysis_ambiguous_lifetime_bound = ambiguous lifetime bound, explicit lifetime bound required -typeck_assoc_type_binding_not_allowed = +hir_analysis_assoc_type_binding_not_allowed = associated type bindings are not allowed here .label = associated type not allowed here -typeck_functional_record_update_on_non_struct = +hir_analysis_functional_record_update_on_non_struct = functional record update syntax requires a struct -typeck_typeof_reserved_keyword_used = +hir_analysis_typeof_reserved_keyword_used = `typeof` is a reserved keyword but unimplemented .suggestion = consider replacing `typeof(...)` with an actual type .label = reserved keyword -typeck_return_stmt_outside_of_fn_body = +hir_analysis_return_stmt_outside_of_fn_body = return statement outside of function body .encl_body_label = the return is part of this body... .encl_fn_label = ...not the enclosing function body -typeck_yield_expr_outside_of_generator = +hir_analysis_yield_expr_outside_of_generator = yield expression outside of generator literal -typeck_struct_expr_non_exhaustive = +hir_analysis_struct_expr_non_exhaustive = cannot create non-exhaustive {$what} using struct expression -typeck_method_call_on_unknown_type = +hir_analysis_method_call_on_unknown_type = the type of this value must be known to call a method on a raw pointer on it -typeck_value_of_associated_struct_already_specified = +hir_analysis_value_of_associated_struct_already_specified = the value of the associated type `{$item_name}` (from trait `{$def_path}`) is already specified .label = re-bound here .previous_bound_label = `{$item_name}` bound here first -typeck_address_of_temporary_taken = cannot take address of a temporary +hir_analysis_address_of_temporary_taken = cannot take address of a temporary .label = temporary value -typeck_add_return_type_add = try adding a return type +hir_analysis_add_return_type_add = try adding a return type -typeck_add_return_type_missing_here = a return type might be missing here +hir_analysis_add_return_type_missing_here = a return type might be missing here -typeck_expected_default_return_type = expected `()` because of default return type +hir_analysis_expected_default_return_type = expected `()` because of default return type -typeck_expected_return_type = expected `{$expected}` because of return type +hir_analysis_expected_return_type = expected `{$expected}` because of return type -typeck_unconstrained_opaque_type = unconstrained opaque type +hir_analysis_unconstrained_opaque_type = unconstrained opaque type .note = `{$name}` must be used in combination with a concrete type within the same module -typeck_missing_type_params = +hir_analysis_missing_type_params = the type {$parameterCount -> [one] parameter *[other] parameters @@ -117,19 +117,19 @@ typeck_missing_type_params = } to {$parameters} .note = because of the default `Self` reference, type parameters must be specified on object types -typeck_manual_implementation = +hir_analysis_manual_implementation = manual implementations of `{$trait_name}` are experimental .label = manual implementations of `{$trait_name}` are experimental .help = add `#![feature(unboxed_closures)]` to the crate attributes to enable -typeck_substs_on_overridden_impl = could not resolve substs on overridden impl +hir_analysis_substs_on_overridden_impl = could not resolve substs on overridden impl -typeck_unused_extern_crate = +hir_analysis_unused_extern_crate = unused extern crate .suggestion = remove it -typeck_extern_crate_not_idiomatic = +hir_analysis_extern_crate_not_idiomatic = `extern crate` is not idiomatic in the new edition .suggestion = convert it to a `{$msg_code}` -typeck_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)` +hir_analysis_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)` diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index bf9248f99b6..18be60975e4 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -40,28 +40,29 @@ fluent_messages! { attr => "../locales/en-US/attr.ftl", borrowck => "../locales/en-US/borrowck.ftl", builtin_macros => "../locales/en-US/builtin_macros.ftl", + compiletest => "../locales/en-US/compiletest.ftl", const_eval => "../locales/en-US/const_eval.ftl", codegen_gcc => "../locales/en-US/codegen_gcc.ftl", driver => "../locales/en-US/driver.ftl", expand => "../locales/en-US/expand.ftl", - session => "../locales/en-US/session.ftl", - interface => "../locales/en-US/interface.ftl", + hir_analysis => "../locales/en-US/hir_analysis.ftl", infer => "../locales/en-US/infer.ftl", + interface => "../locales/en-US/interface.ftl", lint => "../locales/en-US/lint.ftl", + metadata => "../locales/en-US/metadata.ftl", middle => "../locales/en-US/middle.ftl", + mir_dataflow => "../locales/en-US/mir_dataflow.ftl", monomorphize => "../locales/en-US/monomorphize.ftl", - metadata => "../locales/en-US/metadata.ftl", parser => "../locales/en-US/parser.ftl", passes => "../locales/en-US/passes.ftl", plugin_impl => "../locales/en-US/plugin_impl.ftl", privacy => "../locales/en-US/privacy.ftl", query_system => "../locales/en-US/query_system.ftl", - trait_selection => "../locales/en-US/trait_selection.ftl", save_analysis => "../locales/en-US/save_analysis.ftl", - ty_utils => "../locales/en-US/ty_utils.ftl", - typeck => "../locales/en-US/typeck.ftl", - mir_dataflow => "../locales/en-US/mir_dataflow.ftl", + session => "../locales/en-US/session.ftl", symbol_mangling => "../locales/en-US/symbol_mangling.ftl", + trait_selection => "../locales/en-US/trait_selection.ftl", + ty_utils => "../locales/en-US/ty_utils.ftl", } pub use fluent_generated::{self as fluent, DEFAULT_LOCALE_RESOURCES}; diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 44df47e2fa0..d891171b824 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -1,4 +1,5 @@ -//! Errors emitted by typeck. +//! Errors emitted by `hir_analysis`. + use rustc_errors::IntoDiagnostic; use rustc_errors::{error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; @@ -6,18 +7,18 @@ use rustc_middle::ty::Ty; use rustc_span::{symbol::Ident, Span, Symbol}; #[derive(Diagnostic)] -#[diag(typeck::field_multiply_specified_in_initializer, code = "E0062")] +#[diag(hir_analysis::field_multiply_specified_in_initializer, code = "E0062")] pub struct FieldMultiplySpecifiedInInitializer { #[primary_span] #[label] pub span: Span, - #[label(typeck::previous_use_label)] + #[label(hir_analysis::previous_use_label)] pub prev_span: Span, pub ident: Ident, } #[derive(Diagnostic)] -#[diag(typeck::unrecognized_atomic_operation, code = "E0092")] +#[diag(hir_analysis::unrecognized_atomic_operation, code = "E0092")] pub struct UnrecognizedAtomicOperation<'a> { #[primary_span] #[label] @@ -26,7 +27,7 @@ pub struct UnrecognizedAtomicOperation<'a> { } #[derive(Diagnostic)] -#[diag(typeck::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] @@ -37,7 +38,7 @@ pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> { } #[derive(Diagnostic)] -#[diag(typeck::unrecognized_intrinsic_function, code = "E0093")] +#[diag(hir_analysis::unrecognized_intrinsic_function, code = "E0093")] pub struct UnrecognizedIntrinsicFunction { #[primary_span] #[label] @@ -46,19 +47,19 @@ pub struct UnrecognizedIntrinsicFunction { } #[derive(Diagnostic)] -#[diag(typeck::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(typeck::generics_label)] + #[label(hir_analysis::generics_label)] pub generics_span: Option<Span>, pub item_kind: &'static str, pub ident: Ident, } #[derive(Diagnostic)] -#[diag(typeck::drop_impl_on_wrong_item, code = "E0120")] +#[diag(hir_analysis::drop_impl_on_wrong_item, code = "E0120")] pub struct DropImplOnWrongItem { #[primary_span] #[label] @@ -66,18 +67,18 @@ pub struct DropImplOnWrongItem { } #[derive(Diagnostic)] -#[diag(typeck::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(typeck::previous_decl_label)] + #[label(hir_analysis::previous_decl_label)] pub prev_span: Span, } #[derive(Diagnostic)] -#[diag(typeck::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] @@ -85,14 +86,14 @@ pub struct CopyImplOnTypeWithDtor { } #[derive(Diagnostic)] -#[diag(typeck::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(typeck::copy_impl_on_non_adt, code = "E0206")] +#[diag(hir_analysis::copy_impl_on_non_adt, code = "E0206")] pub struct CopyImplOnNonAdt { #[primary_span] #[label] @@ -100,23 +101,23 @@ pub struct CopyImplOnNonAdt { } #[derive(Diagnostic)] -#[diag(typeck::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(typeck::alias_span)] + #[label(hir_analysis::alias_span)] pub trait_alias_span: Option<Span>, } #[derive(Diagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0227")] +#[diag(hir_analysis::ambiguous_lifetime_bound, code = "E0227")] pub struct AmbiguousLifetimeBound { #[primary_span] pub span: Span, } #[derive(Diagnostic)] -#[diag(typeck::assoc_type_binding_not_allowed, code = "E0229")] +#[diag(hir_analysis::assoc_type_binding_not_allowed, code = "E0229")] pub struct AssocTypeBindingNotAllowed { #[primary_span] #[label] @@ -124,14 +125,14 @@ pub struct AssocTypeBindingNotAllowed { } #[derive(Diagnostic)] -#[diag(typeck::functional_record_update_on_non_struct, code = "E0436")] +#[diag(hir_analysis::functional_record_update_on_non_struct, code = "E0436")] pub struct FunctionalRecordUpdateOnNonStruct { #[primary_span] pub span: Span, } #[derive(Diagnostic)] -#[diag(typeck::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] @@ -142,25 +143,25 @@ pub struct TypeofReservedKeywordUsed<'tcx> { } #[derive(Diagnostic)] -#[diag(typeck::return_stmt_outside_of_fn_body, code = "E0572")] +#[diag(hir_analysis::return_stmt_outside_of_fn_body, code = "E0572")] pub struct ReturnStmtOutsideOfFnBody { #[primary_span] pub span: Span, - #[label(typeck::encl_body_label)] + #[label(hir_analysis::encl_body_label)] pub encl_body_span: Option<Span>, - #[label(typeck::encl_fn_label)] + #[label(hir_analysis::encl_fn_label)] pub encl_fn_span: Option<Span>, } #[derive(Diagnostic)] -#[diag(typeck::yield_expr_outside_of_generator, code = "E0627")] +#[diag(hir_analysis::yield_expr_outside_of_generator, code = "E0627")] pub struct YieldExprOutsideOfGenerator { #[primary_span] pub span: Span, } #[derive(Diagnostic)] -#[diag(typeck::struct_expr_non_exhaustive, code = "E0639")] +#[diag(hir_analysis::struct_expr_non_exhaustive, code = "E0639")] pub struct StructExprNonExhaustive { #[primary_span] pub span: Span, @@ -168,26 +169,26 @@ pub struct StructExprNonExhaustive { } #[derive(Diagnostic)] -#[diag(typeck::method_call_on_unknown_type, code = "E0699")] +#[diag(hir_analysis::method_call_on_unknown_type, code = "E0699")] pub struct MethodCallOnUnknownType { #[primary_span] pub span: Span, } #[derive(Diagnostic)] -#[diag(typeck::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(typeck::previous_bound_label)] + #[label(hir_analysis::previous_bound_label)] pub prev_span: Span, pub item_name: Ident, pub def_path: String, } #[derive(Diagnostic)] -#[diag(typeck::address_of_temporary_taken, code = "E0745")] +#[diag(hir_analysis::address_of_temporary_taken, code = "E0745")] pub struct AddressOfTemporaryTaken { #[primary_span] #[label] @@ -197,7 +198,7 @@ pub struct AddressOfTemporaryTaken { #[derive(Subdiagnostic)] pub enum AddReturnTypeSuggestion { #[suggestion( - typeck::add_return_type_add, + hir_analysis::add_return_type_add, code = "-> {found} ", applicability = "machine-applicable" )] @@ -207,7 +208,7 @@ pub enum AddReturnTypeSuggestion { found: String, }, #[suggestion( - typeck::add_return_type_missing_here, + hir_analysis::add_return_type_missing_here, code = "-> _ ", applicability = "has-placeholders" )] @@ -219,12 +220,12 @@ pub enum AddReturnTypeSuggestion { #[derive(Subdiagnostic)] pub enum ExpectedReturnTypeLabel<'tcx> { - #[label(typeck::expected_default_return_type)] + #[label(hir_analysis::expected_default_return_type)] Unit { #[primary_span] span: Span, }, - #[label(typeck::expected_return_type)] + #[label(hir_analysis::expected_return_type)] Other { #[primary_span] span: Span, @@ -233,7 +234,7 @@ pub enum ExpectedReturnTypeLabel<'tcx> { } #[derive(Diagnostic)] -#[diag(typeck::unconstrained_opaque_type)] +#[diag(hir_analysis::unconstrained_opaque_type)] #[note] pub struct UnconstrainedOpaqueType { #[primary_span] @@ -254,7 +255,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::typeck::missing_type_params, + rustc_errors::fluent::hir_analysis::missing_type_params, error_code!(E0393), ); err.set_arg("parameterCount", self.missing_type_params.len()); @@ -267,7 +268,7 @@ impl<'a> IntoDiagnostic<'a> for MissingTypeParams { .join(", "), ); - err.span_label(self.def_span, rustc_errors::fluent::typeck::label); + err.span_label(self.def_span, rustc_errors::fluent::hir_analysis::label); let mut suggested = false; // Don't suggest setting the type params if there are some already: the order is @@ -282,7 +283,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::typeck::suggestion, + rustc_errors::fluent::hir_analysis::suggestion, format!( "{}<{}>", snippet, @@ -298,16 +299,16 @@ impl<'a> IntoDiagnostic<'a> for MissingTypeParams { } } if !suggested { - err.span_label(self.span, rustc_errors::fluent::typeck::no_suggestion_label); + err.span_label(self.span, rustc_errors::fluent::hir_analysis::no_suggestion_label); } - err.note(rustc_errors::fluent::typeck::note); + err.note(rustc_errors::fluent::hir_analysis::note); err } } #[derive(Diagnostic)] -#[diag(typeck::manual_implementation, code = "E0183")] +#[diag(hir_analysis::manual_implementation, code = "E0183")] #[help] pub struct ManualImplementation { #[primary_span] @@ -317,21 +318,21 @@ pub struct ManualImplementation { } #[derive(Diagnostic)] -#[diag(typeck::substs_on_overridden_impl)] +#[diag(hir_analysis::substs_on_overridden_impl)] pub struct SubstsOnOverriddenImpl { #[primary_span] pub span: Span, } #[derive(LintDiagnostic)] -#[diag(typeck::unused_extern_crate)] +#[diag(hir_analysis::unused_extern_crate)] pub struct UnusedExternCrate { #[suggestion(applicability = "machine-applicable", code = "")] pub span: Span, } #[derive(LintDiagnostic)] -#[diag(typeck::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, @@ -340,7 +341,7 @@ pub struct ExternCrateNotIdiomatic { } #[derive(Diagnostic)] -#[diag(typeck::expected_used_symbol)] +#[diag(hir_analysis::expected_used_symbol)] pub struct ExpectedUsedSymbol { #[primary_span] pub span: Span, diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic.rs b/compiler/rustc_macros/src/diagnostics/diagnostic.rs index 3a0bd1ba50d..83040a652b1 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic.rs @@ -36,7 +36,7 @@ impl<'a> DiagnosticDerive<'a> { span_err(builder.span, "diagnostic slug not specified") .help(&format!( "specify the slug as the first argument to the `#[diag(...)]` \ - attribute, such as `#[diag(typeck::example_error)]`", + attribute, such as `#[diag(hir_analysis::example_error)]`", )) .emit(); return DiagnosticDeriveError::ErrorHandled.to_compile_error(); @@ -113,7 +113,7 @@ impl<'a> LintDiagnosticDerive<'a> { span_err(builder.span, "diagnostic slug not specified") .help(&format!( "specify the slug as the first argument to the attribute, such as \ - `#[diag(typeck::example_error)]`", + `#[diag(compiletest::example)]`", )) .emit(); return DiagnosticDeriveError::ErrorHandled.to_compile_error(); |
