summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_attr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /compiler/rustc_attr
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_attr')
-rw-r--r--compiler/rustc_attr/Cargo.toml1
-rw-r--r--compiler/rustc_attr/messages.ftl128
-rw-r--r--compiler/rustc_attr/src/builtin.rs44
-rw-r--r--compiler/rustc_attr/src/lib.rs2
4 files changed, 88 insertions, 87 deletions
diff --git a/compiler/rustc_attr/Cargo.toml b/compiler/rustc_attr/Cargo.toml
index 6349ddf31..2c4c3a0c2 100644
--- a/compiler/rustc_attr/Cargo.toml
+++ b/compiler/rustc_attr/Cargo.toml
@@ -9,6 +9,7 @@ edition = "2021"
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_errors = { path = "../rustc_errors" }
+rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_span = { path = "../rustc_span" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_feature = { path = "../rustc_feature" }
diff --git a/compiler/rustc_attr/messages.ftl b/compiler/rustc_attr/messages.ftl
index a7f8c993d..e6cbbaf37 100644
--- a/compiler/rustc_attr/messages.ftl
+++ b/compiler/rustc_attr/messages.ftl
@@ -1,27 +1,38 @@
+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_one_cfg_pattern =
expected 1 cfg-pattern
-attr_invalid_predicate =
- invalid predicate `{$predicate}`
+attr_expected_single_version_literal =
+ expected single version literal
-attr_multiple_item =
- multiple '{$item}' items
+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_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_incorrect_repr_format_align_one_arg =
+ incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
-attr_missing_note =
- missing 'note'
+attr_incorrect_repr_format_generic =
+ incorrect `repr({$repr_arg})` attribute format
+ .suggestion = use parentheses instead
-attr_multiple_stability_levels =
- multiple stability levels
+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_issue_string =
`issue` must be a non-zero numeric string or "none"
@@ -31,17 +42,15 @@ attr_invalid_issue_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_invalid_predicate =
+ invalid predicate `{$predicate}`
-attr_missing_issue =
- missing 'issue'
+attr_invalid_repr_align_need_arg =
+ invalid `repr(align)` attribute: `align` needs an argument
+ .suggestion = supply an argument here
-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_generic =
+ invalid `repr({$repr_arg})` attribute: {$error_part}
attr_invalid_repr_hint_no_paren =
invalid representation hint: `{$name}` does not take a parenthesized argument list
@@ -49,59 +58,50 @@ attr_invalid_repr_hint_no_paren =
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_missing_feature =
+ missing 'feature'
-attr_invalid_repr_align_need_arg =
- invalid `repr(align)` attribute: `align` needs an argument
- .suggestion = supply an argument here
+attr_missing_issue =
+ missing 'issue'
-attr_invalid_repr_generic =
- invalid `repr({$repr_arg})` attribute: {$error_part}
+attr_missing_note =
+ missing 'note'
-attr_incorrect_repr_format_align_one_arg =
- incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
+attr_missing_since =
+ missing 'since'
-attr_incorrect_repr_format_generic =
- incorrect `repr({$repr_arg})` attribute format
- .suggestion = use parentheses instead
+attr_multiple_item =
+ multiple '{$item}' items
-attr_rustc_promotable_pairing =
- `rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute
+attr_multiple_stability_levels =
+ multiple stability levels
+
+attr_non_ident_feature =
+ 'feature' is not an identifier
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_rustc_promotable_pairing =
+ `rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute
attr_soft_no_args =
`soft` should not have any arguments
+attr_unknown_meta_item =
+ unknown meta item '{$item}'
+ .label = expected one of {$expected}
+
attr_unknown_version_literal =
unknown version literal format, assuming it refers to a future version
+
+attr_unsupported_literal_cfg_string =
+ literal in `cfg` predicate value must be a string
+attr_unsupported_literal_deprecated_kv_pair =
+ item in `deprecated` must be a key/value pair
+attr_unsupported_literal_deprecated_string =
+ literal in `deprecated` value must be a string
+attr_unsupported_literal_generic =
+ unsupported literal
+attr_unsupported_literal_suggestion =
+ consider removing the prefix
diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs
index cb217be66..372a58857 100644
--- a/compiler/rustc_attr/src/builtin.rs
+++ b/compiler/rustc_attr/src/builtin.rs
@@ -5,6 +5,7 @@ use rustc_ast::{Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedM
use rustc_ast_pretty::pprust;
use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg};
use rustc_macros::HashStable_Generic;
+use rustc_session::config::ExpectedValues;
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
use rustc_session::lint::BuiltinLintDiagnostics;
use rustc_session::parse::{feature_err, ParseSess};
@@ -22,8 +23,7 @@ use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
pub fn rust_version_symbol() -> Symbol {
- let version = option_env!("CFG_VERSION").unwrap_or("<current>");
- let version = version.split(' ').next().unwrap();
+ let version = option_env!("CFG_RELEASE").unwrap_or("<current>");
Symbol::intern(&version)
}
@@ -581,32 +581,32 @@ pub fn cfg_matches(
) -> bool {
eval_condition(cfg, sess, features, &mut |cfg| {
try_gate_cfg(cfg.name, cfg.span, sess, features);
- if let Some(names_valid) = &sess.check_config.names_valid {
- if !names_valid.contains(&cfg.name) {
+ match sess.check_config.expecteds.get(&cfg.name) {
+ Some(ExpectedValues::Some(values)) if !values.contains(&cfg.value) => {
sess.buffer_lint_with_diagnostic(
UNEXPECTED_CFGS,
cfg.span,
lint_node_id,
- "unexpected `cfg` condition name",
- BuiltinLintDiagnostics::UnexpectedCfg((cfg.name, cfg.name_span), None),
+ "unexpected `cfg` condition value",
+ BuiltinLintDiagnostics::UnexpectedCfgValue(
+ (cfg.name, cfg.name_span),
+ cfg.value.map(|v| (v, cfg.value_span.unwrap())),
+ ),
);
}
- }
- if let Some(value) = cfg.value {
- if let Some(values) = &sess.check_config.values_valid.get(&cfg.name) {
- if !values.contains(&value) {
- sess.buffer_lint_with_diagnostic(
- UNEXPECTED_CFGS,
- cfg.span,
- lint_node_id,
- "unexpected `cfg` condition value",
- BuiltinLintDiagnostics::UnexpectedCfg(
- (cfg.name, cfg.name_span),
- cfg.value_span.map(|vs| (value, vs)),
- ),
- );
- }
+ None if sess.check_config.exhaustive_names => {
+ sess.buffer_lint_with_diagnostic(
+ UNEXPECTED_CFGS,
+ cfg.span,
+ lint_node_id,
+ "unexpected `cfg` condition name",
+ BuiltinLintDiagnostics::UnexpectedCfgName(
+ (cfg.name, cfg.name_span),
+ cfg.value.map(|v| (v, cfg.value_span.unwrap())),
+ ),
+ );
}
+ _ => { /* not unexpected */ }
}
sess.config.contains(&(cfg.name, cfg.value))
})
@@ -623,7 +623,7 @@ fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &ParseSess, features: &F
let (cfg, feature, has_feature) = gated_cfg;
if !has_feature(features) && !cfg_span.allows_unstable(*feature) {
let explain = format!("`cfg({cfg})` is experimental and subject to change");
- feature_err(sess, *feature, cfg_span, &explain).emit();
+ feature_err(sess, *feature, cfg_span, explain).emit();
}
}
diff --git a/compiler/rustc_attr/src/lib.rs b/compiler/rustc_attr/src/lib.rs
index 49818c14f..cfed2acfb 100644
--- a/compiler/rustc_attr/src/lib.rs
+++ b/compiler/rustc_attr/src/lib.rs
@@ -12,7 +12,7 @@
extern crate rustc_macros;
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
-use rustc_macros::fluent_messages;
+use rustc_fluent_macro::fluent_messages;
mod builtin;
mod session_diagnostics;