diff options
Diffstat (limited to 'compiler/rustc_attr')
-rw-r--r-- | compiler/rustc_attr/locales/en-US.ftl | 107 | ||||
-rw-r--r-- | compiler/rustc_attr/src/builtin.rs | 2 | ||||
-rw-r--r-- | compiler/rustc_attr/src/lib.rs | 5 | ||||
-rw-r--r-- | compiler/rustc_attr/src/session_diagnostics.rs | 19 |
4 files changed, 123 insertions, 10 deletions
diff --git a/compiler/rustc_attr/locales/en-US.ftl b/compiler/rustc_attr/locales/en-US.ftl new file mode 100644 index 000000000..a7f8c993d --- /dev/null +++ b/compiler/rustc_attr/locales/en-US.ftl @@ -0,0 +1,107 @@ +attr_expected_one_cfg_pattern = + expected 1 cfg-pattern + +attr_invalid_predicate = + invalid predicate `{$predicate}` + +attr_multiple_item = + multiple '{$item}' items + +attr_incorrect_meta_item = + incorrect meta item + +attr_unknown_meta_item = + unknown meta item '{$item}' + .label = expected one of {$expected} + +attr_missing_since = + missing 'since' + +attr_missing_note = + missing 'note' + +attr_multiple_stability_levels = + multiple stability levels + +attr_invalid_issue_string = + `issue` must be a non-zero numeric string or "none" + .must_not_be_zero = `issue` must not be "0", use "none" instead + .empty = cannot parse integer from empty string + .invalid_digit = invalid digit found in string + .pos_overflow = number too large to fit in target type + .neg_overflow = number too small to fit in target type + +attr_missing_feature = + missing 'feature' + +attr_non_ident_feature = + 'feature' is not an identifier + +attr_missing_issue = + missing 'issue' + +attr_incorrect_repr_format_packed_one_or_zero_arg = + incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all + +attr_invalid_repr_hint_no_paren = + invalid representation hint: `{$name}` does not take a parenthesized argument list + +attr_invalid_repr_hint_no_value = + invalid representation hint: `{$name}` does not take a value + +attr_unsupported_literal_generic = + unsupported literal +attr_unsupported_literal_cfg_string = + literal in `cfg` predicate value must be a string +attr_unsupported_literal_deprecated_string = + literal in `deprecated` value must be a string +attr_unsupported_literal_deprecated_kv_pair = + item in `deprecated` must be a key/value pair +attr_unsupported_literal_suggestion = + consider removing the prefix + +attr_invalid_repr_align_need_arg = + invalid `repr(align)` attribute: `align` needs an argument + .suggestion = supply an argument here + +attr_invalid_repr_generic = + invalid `repr({$repr_arg})` attribute: {$error_part} + +attr_incorrect_repr_format_align_one_arg = + incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses + +attr_incorrect_repr_format_generic = + incorrect `repr({$repr_arg})` attribute format + .suggestion = use parentheses instead + +attr_rustc_promotable_pairing = + `rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute + +attr_rustc_allowed_unstable_pairing = + `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute + +attr_cfg_predicate_identifier = + `cfg` predicate key must be an identifier + +attr_deprecated_item_suggestion = + suggestions on deprecated items are unstable + .help = add `#![feature(deprecated_suggestion)]` to the crate root + .note = see #94785 for more details + +attr_expected_single_version_literal = + expected single version literal + +attr_expected_version_literal = + expected a version literal + +attr_expects_feature_list = + `{$name}` expects a list of feature names + +attr_expects_features = + `{$name}` expects feature names + +attr_soft_no_args = + `soft` should not have any arguments + +attr_unknown_version_literal = + unknown version literal format, assuming it refers to a future version diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 40531c1c1..3d240108b 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -731,7 +731,7 @@ pub fn eval_condition( sess, sym::cfg_target_compact, cfg.span, - &"compact `cfg(target(..))` is experimental and subject to change" + "compact `cfg(target(..))` is experimental and subject to change" ).emit(); } diff --git a/compiler/rustc_attr/src/lib.rs b/compiler/rustc_attr/src/lib.rs index 4580ffcc6..5fede0a58 100644 --- a/compiler/rustc_attr/src/lib.rs +++ b/compiler/rustc_attr/src/lib.rs @@ -11,6 +11,9 @@ #[macro_use] extern crate rustc_macros; +use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; +use rustc_macros::fluent_messages; + mod builtin; mod session_diagnostics; @@ -22,3 +25,5 @@ pub use StabilityLevel::*; pub use rustc_ast::attr::*; pub(crate) use rustc_ast::HashStableContext; + +fluent_messages! { "../locales/en-US.ftl" } diff --git a/compiler/rustc_attr/src/session_diagnostics.rs b/compiler/rustc_attr/src/session_diagnostics.rs index 3ba7a3c53..ee79545e3 100644 --- a/compiler/rustc_attr/src/session_diagnostics.rs +++ b/compiler/rustc_attr/src/session_diagnostics.rs @@ -2,11 +2,12 @@ use std::num::IntErrorKind; use rustc_ast as ast; use rustc_errors::{ - error_code, fluent, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, + error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, }; use rustc_macros::Diagnostic; use rustc_span::{Span, Symbol}; +use crate::fluent_generated as fluent; use crate::UnsupportedLiteralReason; #[derive(Diagnostic)] @@ -59,7 +60,7 @@ impl<'a> IntoDiagnostic<'a> for UnknownMetaItem<'_> { ); diag.set_arg("item", self.item); diag.set_arg("expected", expected.join(", ")); - diag.span_label(self.span, fluent::label); + diag.span_label(self.span, fluent::attr_label); diag } } @@ -99,31 +100,31 @@ pub(crate) struct InvalidIssueString { // translatable. #[derive(Subdiagnostic)] pub(crate) enum InvalidIssueStringCause { - #[label(must_not_be_zero)] + #[label(attr_must_not_be_zero)] MustNotBeZero { #[primary_span] span: Span, }, - #[label(empty)] + #[label(attr_empty)] Empty { #[primary_span] span: Span, }, - #[label(invalid_digit)] + #[label(attr_invalid_digit)] InvalidDigit { #[primary_span] span: Span, }, - #[label(pos_overflow)] + #[label(attr_pos_overflow)] PosOverflow { #[primary_span] span: Span, }, - #[label(neg_overflow)] + #[label(attr_neg_overflow)] NegOverflow { #[primary_span] span: Span, @@ -275,7 +276,7 @@ pub(crate) struct IncorrectReprFormatGeneric<'a> { #[derive(Subdiagnostic)] pub(crate) enum IncorrectReprFormatGenericCause<'a> { - #[suggestion(suggestion, code = "{name}({int})", applicability = "machine-applicable")] + #[suggestion(attr_suggestion, code = "{name}({int})", applicability = "machine-applicable")] Int { #[primary_span] span: Span, @@ -287,7 +288,7 @@ pub(crate) enum IncorrectReprFormatGenericCause<'a> { int: u128, }, - #[suggestion(suggestion, code = "{name}({symbol})", applicability = "machine-applicable")] + #[suggestion(attr_suggestion, code = "{name}({symbol})", applicability = "machine-applicable")] Symbol { #[primary_span] span: Span, |