Pass a Symbol to check_name, emit_feature_err, and related functions.
This commit is contained in:
parent
79602c87b5
commit
fb084a48e2
114 changed files with 671 additions and 621 deletions
|
|
@ -48,8 +48,8 @@ macro_rules! declare_features {
|
|||
/// Represents active features that are currently being implemented or
|
||||
/// currently being considered for addition/removal.
|
||||
const ACTIVE_FEATURES:
|
||||
&[(&str, &str, Option<u32>, Option<Edition>, fn(&mut Features, Span))] =
|
||||
&[$((stringify!($feature), $ver, $issue, $edition, set!($feature))),+];
|
||||
&[(Symbol, &str, Option<u32>, Option<Edition>, fn(&mut Features, Span))] =
|
||||
&[$((sym::$feature, $ver, $issue, $edition, set!($feature))),+];
|
||||
|
||||
/// A set of features to be used by later passes.
|
||||
#[derive(Clone)]
|
||||
|
|
@ -80,22 +80,22 @@ macro_rules! declare_features {
|
|||
|
||||
($((removed, $feature: ident, $ver: expr, $issue: expr, None, $reason: expr),)+) => {
|
||||
/// Represents unstable features which have since been removed (it was once Active)
|
||||
const REMOVED_FEATURES: &[(&str, &str, Option<u32>, Option<&str>)] = &[
|
||||
$((stringify!($feature), $ver, $issue, $reason)),+
|
||||
const REMOVED_FEATURES: &[(Symbol, &str, Option<u32>, Option<&str>)] = &[
|
||||
$((sym::$feature, $ver, $issue, $reason)),+
|
||||
];
|
||||
};
|
||||
|
||||
($((stable_removed, $feature: ident, $ver: expr, $issue: expr, None),)+) => {
|
||||
/// Represents stable features which have since been removed (it was once Accepted)
|
||||
const STABLE_REMOVED_FEATURES: &[(&str, &str, Option<u32>, Option<&str>)] = &[
|
||||
$((stringify!($feature), $ver, $issue, None)),+
|
||||
const STABLE_REMOVED_FEATURES: &[(Symbol, &str, Option<u32>, Option<&str>)] = &[
|
||||
$((sym::$feature, $ver, $issue, None)),+
|
||||
];
|
||||
};
|
||||
|
||||
($((accepted, $feature: ident, $ver: expr, $issue: expr, None),)+) => {
|
||||
/// Those language feature has since been Accepted (it was once Active)
|
||||
const ACCEPTED_FEATURES: &[(&str, &str, Option<u32>, Option<&str>)] = &[
|
||||
$((stringify!($feature), $ver, $issue, None)),+
|
||||
const ACCEPTED_FEATURES: &[(Symbol, &str, Option<u32>, Option<&str>)] = &[
|
||||
$((sym::$feature, $ver, $issue, None)),+
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -860,7 +860,7 @@ pub enum AttributeType {
|
|||
pub enum AttributeGate {
|
||||
/// Is gated by a given feature gate, reason
|
||||
/// and function to check if enabled
|
||||
Gated(Stability, &'static str, &'static str, fn(&Features) -> bool),
|
||||
Gated(Stability, Symbol, &'static str, fn(&Features) -> bool),
|
||||
|
||||
/// Ungated attribute, can be used on all release channels
|
||||
Ungated,
|
||||
|
|
@ -1010,7 +1010,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
(sym::no_implicit_prelude, Normal, template!(Word), Ungated),
|
||||
(sym::reexport_test_harness_main, Normal, template!(NameValueStr: "name"), Ungated),
|
||||
(sym::link_args, Normal, template!(NameValueStr: "args"), Gated(Stability::Unstable,
|
||||
"link_args",
|
||||
sym::link_args,
|
||||
"the `link_args` attribute is experimental and not \
|
||||
portable across platforms, it is recommended to \
|
||||
use `#[link(name = \"foo\")] instead",
|
||||
|
|
@ -1019,46 +1019,46 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
|
||||
// RFC #1445.
|
||||
(sym::structural_match, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"structural_match",
|
||||
sym::structural_match,
|
||||
"the semantics of constant patterns is \
|
||||
not yet settled",
|
||||
cfg_fn!(structural_match))),
|
||||
|
||||
// RFC #2008
|
||||
(sym::non_exhaustive, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"non_exhaustive",
|
||||
sym::non_exhaustive,
|
||||
"non exhaustive is an experimental feature",
|
||||
cfg_fn!(non_exhaustive))),
|
||||
|
||||
// RFC #1268
|
||||
(sym::marker, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"marker_trait_attr",
|
||||
sym::marker_trait_attr,
|
||||
"marker traits is an experimental feature",
|
||||
cfg_fn!(marker_trait_attr))),
|
||||
|
||||
(sym::plugin, CrateLevel, template!(List: "name|name(args)"), Gated(Stability::Unstable,
|
||||
"plugin",
|
||||
sym::plugin,
|
||||
"compiler plugins are experimental \
|
||||
and possibly buggy",
|
||||
cfg_fn!(plugin))),
|
||||
|
||||
(sym::no_std, CrateLevel, template!(Word), Ungated),
|
||||
(sym::no_core, CrateLevel, template!(Word), Gated(Stability::Unstable,
|
||||
"no_core",
|
||||
sym::no_core,
|
||||
"no_core is experimental",
|
||||
cfg_fn!(no_core))),
|
||||
(sym::lang, Normal, template!(NameValueStr: "name"), Gated(Stability::Unstable,
|
||||
"lang_items",
|
||||
sym::lang_items,
|
||||
"language items are subject to change",
|
||||
cfg_fn!(lang_items))),
|
||||
(sym::linkage, Whitelisted, template!(NameValueStr: "external|internal|..."),
|
||||
Gated(Stability::Unstable,
|
||||
"linkage",
|
||||
sym::linkage,
|
||||
"the `linkage` attribute is experimental \
|
||||
and not portable across platforms",
|
||||
cfg_fn!(linkage))),
|
||||
(sym::thread_local, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"thread_local",
|
||||
sym::thread_local,
|
||||
"`#[thread_local]` is an experimental feature, and does \
|
||||
not currently handle destructors",
|
||||
cfg_fn!(thread_local))),
|
||||
|
|
@ -1067,100 +1067,100 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#,
|
||||
NameValueStr: "message"),
|
||||
Gated(Stability::Unstable,
|
||||
"on_unimplemented",
|
||||
sym::on_unimplemented,
|
||||
"the `#[rustc_on_unimplemented]` attribute \
|
||||
is an experimental feature",
|
||||
cfg_fn!(on_unimplemented))),
|
||||
(sym::rustc_const_unstable, Normal, template!(List: r#"feature = "name""#),
|
||||
Gated(Stability::Unstable,
|
||||
"rustc_const_unstable",
|
||||
sym::rustc_const_unstable,
|
||||
"the `#[rustc_const_unstable]` attribute \
|
||||
is an internal feature",
|
||||
cfg_fn!(rustc_const_unstable))),
|
||||
(sym::global_allocator, Normal, template!(Word), Ungated),
|
||||
(sym::default_lib_allocator, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"allocator_internals",
|
||||
sym::allocator_internals,
|
||||
"the `#[default_lib_allocator]` \
|
||||
attribute is an experimental feature",
|
||||
cfg_fn!(allocator_internals))),
|
||||
(sym::needs_allocator, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"allocator_internals",
|
||||
sym::allocator_internals,
|
||||
"the `#[needs_allocator]` \
|
||||
attribute is an experimental \
|
||||
feature",
|
||||
cfg_fn!(allocator_internals))),
|
||||
(sym::panic_runtime, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"panic_runtime",
|
||||
sym::panic_runtime,
|
||||
"the `#[panic_runtime]` attribute is \
|
||||
an experimental feature",
|
||||
cfg_fn!(panic_runtime))),
|
||||
(sym::needs_panic_runtime, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"needs_panic_runtime",
|
||||
sym::needs_panic_runtime,
|
||||
"the `#[needs_panic_runtime]` \
|
||||
attribute is an experimental \
|
||||
feature",
|
||||
cfg_fn!(needs_panic_runtime))),
|
||||
(sym::rustc_outlives, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_outlives]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_variance, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_variance]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_layout, Normal, template!(List: "field1, field2, ..."),
|
||||
Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_layout]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_layout_scalar_valid_range_start, Whitelisted, template!(List: "value"),
|
||||
Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_layout_scalar_valid_range_start]` attribute \
|
||||
is just used to enable niche optimizations in libcore \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_layout_scalar_valid_range_end, Whitelisted, template!(List: "value"),
|
||||
Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_layout_scalar_valid_range_end]` attribute \
|
||||
is just used to enable niche optimizations in libcore \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_regions, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_regions]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_error, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_error]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_dump_user_substs, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"this attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_if_this_changed, Whitelisted, template!(Word, List: "DepNode"),
|
||||
Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_if_this_changed]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_then_this_would_need, Whitelisted, template!(List: "DepNode"),
|
||||
Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_if_this_changed]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
|
|
@ -1168,7 +1168,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
(sym::rustc_dirty, Whitelisted, template!(List: r#"cfg = "...", /*opt*/ label = "...",
|
||||
/*opt*/ except = "...""#),
|
||||
Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_dirty]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
|
|
@ -1176,7 +1176,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
(sym::rustc_clean, Whitelisted, template!(List: r#"cfg = "...", /*opt*/ label = "...",
|
||||
/*opt*/ except = "...""#),
|
||||
Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_clean]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
|
|
@ -1187,7 +1187,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
template!(List: r#"cfg = "...", module = "...""#),
|
||||
Gated(
|
||||
Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"this attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
|
|
@ -1200,7 +1200,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
template!(List: r#"cfg = "...", module = "...""#),
|
||||
Gated(
|
||||
Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"this attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
|
|
@ -1210,27 +1210,27 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
(sym::rustc_expected_cgu_reuse, Whitelisted, template!(List: r#"cfg = "...", module = "...",
|
||||
kind = "...""#),
|
||||
Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"this attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_synthetic, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"this attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_symbol_name, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"internal rustc attributes will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_def_path, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"internal rustc attributes will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_mir, Whitelisted, template!(List: "arg1, arg2, ..."), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_mir]` attribute \
|
||||
is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
|
|
@ -1241,7 +1241,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
template!(Word),
|
||||
Gated(
|
||||
Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_inherit_overflow_checks]` \
|
||||
attribute is just used to control \
|
||||
overflow checking behavior of several \
|
||||
|
|
@ -1252,35 +1252,35 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
),
|
||||
|
||||
(sym::rustc_dump_program_clauses, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_dump_program_clauses]` \
|
||||
attribute is just used for rustc unit \
|
||||
tests and will never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_test_marker, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"the `#[rustc_test_marker]` attribute \
|
||||
is used internally to track tests",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::rustc_transparent_macro, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"used internally for testing macro hygiene",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
(sym::compiler_builtins, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"compiler_builtins",
|
||||
sym::compiler_builtins,
|
||||
"the `#[compiler_builtins]` attribute is used to \
|
||||
identify the `compiler_builtins` crate which \
|
||||
contains compiler-rt intrinsics and will never be \
|
||||
stable",
|
||||
cfg_fn!(compiler_builtins))),
|
||||
(sym::sanitizer_runtime, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"sanitizer_runtime",
|
||||
sym::sanitizer_runtime,
|
||||
"the `#[sanitizer_runtime]` attribute is used to \
|
||||
identify crates that contain the runtime of a \
|
||||
sanitizer and will never be stable",
|
||||
cfg_fn!(sanitizer_runtime))),
|
||||
(sym::profiler_runtime, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"profiler_runtime",
|
||||
sym::profiler_runtime,
|
||||
"the `#[profiler_runtime]` attribute is used to \
|
||||
identify the `profiler_builtins` crate which \
|
||||
contains the profiler runtime and will never be \
|
||||
|
|
@ -1289,17 +1289,17 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
|
||||
(sym::allow_internal_unstable, Normal, template!(Word, List: "feat1, feat2, ..."),
|
||||
Gated(Stability::Unstable,
|
||||
"allow_internal_unstable",
|
||||
sym::allow_internal_unstable,
|
||||
EXPLAIN_ALLOW_INTERNAL_UNSTABLE,
|
||||
cfg_fn!(allow_internal_unstable))),
|
||||
|
||||
(sym::allow_internal_unsafe, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"allow_internal_unsafe",
|
||||
sym::allow_internal_unsafe,
|
||||
EXPLAIN_ALLOW_INTERNAL_UNSAFE,
|
||||
cfg_fn!(allow_internal_unsafe))),
|
||||
|
||||
(sym::fundamental, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"fundamental",
|
||||
sym::fundamental,
|
||||
"the `#[fundamental]` attribute \
|
||||
is an experimental feature",
|
||||
cfg_fn!(fundamental))),
|
||||
|
|
@ -1309,7 +1309,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
Ungated),
|
||||
|
||||
(sym::rustc_copy_clone_marker, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"internal implementation detail",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
|
||||
|
|
@ -1325,12 +1325,12 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
// lint pass
|
||||
(sym::cold, Whitelisted, template!(Word), Ungated),
|
||||
(sym::naked, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"naked_functions",
|
||||
sym::naked_functions,
|
||||
"the `#[naked]` attribute \
|
||||
is an experimental feature",
|
||||
cfg_fn!(naked_functions))),
|
||||
(sym::ffi_returns_twice, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"ffi_returns_twice",
|
||||
sym::ffi_returns_twice,
|
||||
"the `#[ffi_returns_twice]` attribute \
|
||||
is an experimental feature",
|
||||
cfg_fn!(ffi_returns_twice))),
|
||||
|
|
@ -1344,7 +1344,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
(sym::no_builtins, Whitelisted, template!(Word), Ungated),
|
||||
(sym::no_debug, Whitelisted, template!(Word), Gated(
|
||||
Stability::Deprecated("https://github.com/rust-lang/rust/issues/29721", None),
|
||||
"no_debug",
|
||||
sym::no_debug,
|
||||
"the `#[no_debug]` attribute was an experimental feature that has been \
|
||||
deprecated due to lack of demand",
|
||||
cfg_fn!(no_debug))),
|
||||
|
|
@ -1354,7 +1354,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
template!(Word),
|
||||
Gated(
|
||||
Stability::Unstable,
|
||||
"omit_gdb_pretty_printer_section",
|
||||
sym::omit_gdb_pretty_printer_section,
|
||||
"the `#[omit_gdb_pretty_printer_section]` \
|
||||
attribute is just used for the Rust test \
|
||||
suite",
|
||||
|
|
@ -1366,7 +1366,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
template!(Word),
|
||||
Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/34761",
|
||||
Some("replace this attribute with `#[may_dangle]`")),
|
||||
"dropck_parametricity",
|
||||
sym::dropck_parametricity,
|
||||
"unsafe_destructor_blind_to_params has been replaced by \
|
||||
may_dangle and will be removed in the future",
|
||||
cfg_fn!(dropck_parametricity))),
|
||||
|
|
@ -1374,18 +1374,18 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
Normal,
|
||||
template!(Word),
|
||||
Gated(Stability::Unstable,
|
||||
"dropck_eyepatch",
|
||||
sym::dropck_eyepatch,
|
||||
"may_dangle has unstable semantics and may be removed in the future",
|
||||
cfg_fn!(dropck_eyepatch))),
|
||||
(sym::unwind, Whitelisted, template!(List: "allowed|aborts"), Gated(Stability::Unstable,
|
||||
"unwind_attributes",
|
||||
sym::unwind_attributes,
|
||||
"#[unwind] is experimental",
|
||||
cfg_fn!(unwind_attributes))),
|
||||
(sym::used, Whitelisted, template!(Word), Ungated),
|
||||
|
||||
// used in resolve
|
||||
(sym::prelude_import, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"prelude_import",
|
||||
sym::prelude_import,
|
||||
"`#[prelude_import]` is for use by rustc only",
|
||||
cfg_fn!(prelude_import))),
|
||||
|
||||
|
|
@ -1421,7 +1421,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
),
|
||||
|
||||
(sym::rustc_paren_sugar, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"unboxed_closures",
|
||||
sym::unboxed_closures,
|
||||
"unboxed_closures are still evolving",
|
||||
cfg_fn!(unboxed_closures))),
|
||||
|
||||
|
|
@ -1431,24 +1431,24 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
(sym::proc_macro, Normal, template!(Word), Ungated),
|
||||
|
||||
(sym::rustc_proc_macro_decls, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"used internally by rustc",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
|
||||
(sym::allow_fail, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"allow_fail",
|
||||
sym::allow_fail,
|
||||
"allow_fail attribute is currently unstable",
|
||||
cfg_fn!(allow_fail))),
|
||||
|
||||
(sym::rustc_std_internal_symbol, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"this is an internal attribute that will \
|
||||
never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
|
||||
// whitelists "identity-like" conversion methods to suggest on type mismatch
|
||||
(sym::rustc_conversion_suggestion, Whitelisted, template!(Word), Gated(Stability::Unstable,
|
||||
"rustc_attrs",
|
||||
sym::rustc_attrs,
|
||||
"this is an internal attribute that will \
|
||||
never be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
|
|
@ -1457,19 +1457,20 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
sym::rustc_args_required_const,
|
||||
Whitelisted,
|
||||
template!(List: "N"),
|
||||
Gated(Stability::Unstable, "rustc_attrs", "never will be stable", cfg_fn!(rustc_attrs))
|
||||
Gated(Stability::Unstable, sym::rustc_attrs, "never will be stable",
|
||||
cfg_fn!(rustc_attrs))
|
||||
),
|
||||
// RFC 2070
|
||||
(sym::panic_handler, Normal, template!(Word), Ungated),
|
||||
|
||||
(sym::alloc_error_handler, Normal, template!(Word), Gated(Stability::Unstable,
|
||||
"alloc_error_handler",
|
||||
sym::alloc_error_handler,
|
||||
"#[alloc_error_handler] is an unstable feature",
|
||||
cfg_fn!(alloc_error_handler))),
|
||||
|
||||
// RFC 2412
|
||||
(sym::optimize, Whitelisted, template!(List: "size|speed"), Gated(Stability::Unstable,
|
||||
"optimize_attribute",
|
||||
sym::optimize_attribute,
|
||||
"#[optimize] attribute is an unstable feature",
|
||||
cfg_fn!(optimize_attribute))),
|
||||
|
||||
|
|
@ -1483,7 +1484,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
(sym::recursion_limit, CrateLevel, template!(NameValueStr: "N"), Ungated),
|
||||
(sym::type_length_limit, CrateLevel, template!(NameValueStr: "N"), Ungated),
|
||||
(sym::test_runner, CrateLevel, template!(List: "path"), Gated(Stability::Unstable,
|
||||
"custom_test_frameworks",
|
||||
sym::custom_test_frameworks,
|
||||
EXPLAIN_CUSTOM_TEST_FRAMEWORKS,
|
||||
cfg_fn!(custom_test_frameworks))),
|
||||
];
|
||||
|
|
@ -1503,11 +1504,11 @@ lazy_static! {
|
|||
}
|
||||
|
||||
// cfg(...)'s that are feature gated
|
||||
const GATED_CFGS: &[(&str, &str, fn(&Features) -> bool)] = &[
|
||||
const GATED_CFGS: &[(Symbol, Symbol, fn(&Features) -> bool)] = &[
|
||||
// (name in cfg, feature, function to check if the feature is enabled)
|
||||
("target_thread_local", "cfg_target_thread_local", cfg_fn!(cfg_target_thread_local)),
|
||||
("target_has_atomic", "cfg_target_has_atomic", cfg_fn!(cfg_target_has_atomic)),
|
||||
("rustdoc", "doc_cfg", cfg_fn!(doc_cfg)),
|
||||
(sym::target_thread_local, sym::cfg_target_thread_local, cfg_fn!(cfg_target_thread_local)),
|
||||
(sym::target_has_atomic, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),
|
||||
(sym::rustdoc, sym::doc_cfg, cfg_fn!(doc_cfg)),
|
||||
];
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -1540,7 +1541,7 @@ impl GatedCfg {
|
|||
struct Context<'a> {
|
||||
features: &'a Features,
|
||||
parse_sess: &'a ParseSess,
|
||||
plugin_attributes: &'a [(String, AttributeType)],
|
||||
plugin_attributes: &'a [(Symbol, AttributeType)],
|
||||
}
|
||||
|
||||
macro_rules! gate_feature_fn {
|
||||
|
|
@ -1559,11 +1560,11 @@ macro_rules! gate_feature_fn {
|
|||
macro_rules! gate_feature {
|
||||
($cx: expr, $feature: ident, $span: expr, $explain: expr) => {
|
||||
gate_feature_fn!($cx, |x:&Features| x.$feature, $span,
|
||||
stringify!($feature), $explain, GateStrength::Hard)
|
||||
sym::$feature, $explain, GateStrength::Hard)
|
||||
};
|
||||
($cx: expr, $feature: ident, $span: expr, $explain: expr, $level: expr) => {
|
||||
gate_feature_fn!($cx, |x:&Features| x.$feature, $span,
|
||||
stringify!($feature), $explain, $level)
|
||||
sym::$feature, $explain, $level)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1594,8 +1595,8 @@ impl<'a> Context<'a> {
|
|||
debug!("check_attribute: {:?} is builtin, {:?}, {:?}", attr.path, ty, gateage);
|
||||
return;
|
||||
}
|
||||
for &(ref n, ref ty) in self.plugin_attributes {
|
||||
if attr.path == &**n {
|
||||
for &(n, ty) in self.plugin_attributes {
|
||||
if attr.path == n {
|
||||
// Plugins can't gate attributes, so we don't check for it
|
||||
// unlike the code above; we only use this loop to
|
||||
// short-circuit to avoid the checks below.
|
||||
|
|
@ -1629,7 +1630,7 @@ pub fn check_attribute(attr: &ast::Attribute, parse_sess: &ParseSess, features:
|
|||
);
|
||||
}
|
||||
|
||||
fn find_lang_feature_issue(feature: &str) -> Option<u32> {
|
||||
fn find_lang_feature_issue(feature: Symbol) -> Option<u32> {
|
||||
if let Some(info) = ACTIVE_FEATURES.iter().find(|t| t.0 == feature) {
|
||||
let issue = info.2;
|
||||
// FIXME (#28244): enforce that active features have issue numbers
|
||||
|
|
@ -1661,7 +1662,7 @@ pub enum GateStrength {
|
|||
|
||||
pub fn emit_feature_err(
|
||||
sess: &ParseSess,
|
||||
feature: &str,
|
||||
feature: Symbol,
|
||||
span: Span,
|
||||
issue: GateIssue,
|
||||
explain: &str,
|
||||
|
|
@ -1671,7 +1672,7 @@ pub fn emit_feature_err(
|
|||
|
||||
pub fn feature_err<'a>(
|
||||
sess: &'a ParseSess,
|
||||
feature: &str,
|
||||
feature: Symbol,
|
||||
span: Span,
|
||||
issue: GateIssue,
|
||||
explain: &str,
|
||||
|
|
@ -1681,7 +1682,7 @@ pub fn feature_err<'a>(
|
|||
|
||||
fn leveled_feature_err<'a>(
|
||||
sess: &'a ParseSess,
|
||||
feature: &str,
|
||||
feature: Symbol,
|
||||
span: Span,
|
||||
issue: GateIssue,
|
||||
explain: &str,
|
||||
|
|
@ -1769,13 +1770,13 @@ struct PostExpansionVisitor<'a> {
|
|||
macro_rules! gate_feature_post {
|
||||
($cx: expr, $feature: ident, $span: expr, $explain: expr) => {{
|
||||
let (cx, span) = ($cx, $span);
|
||||
if !span.allows_unstable(stringify!($feature)) {
|
||||
if !span.allows_unstable(sym::$feature) {
|
||||
gate_feature!(cx.context, $feature, span, $explain)
|
||||
}
|
||||
}};
|
||||
($cx: expr, $feature: ident, $span: expr, $explain: expr, $level: expr) => {{
|
||||
let (cx, span) = ($cx, $span);
|
||||
if !span.allows_unstable(stringify!($feature)) {
|
||||
if !span.allows_unstable(sym::$feature) {
|
||||
gate_feature!(cx.context, $feature, span, $explain, $level)
|
||||
}
|
||||
}}
|
||||
|
|
@ -1957,17 +1958,17 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||
}
|
||||
|
||||
ast::ItemKind::Fn(..) => {
|
||||
if attr::contains_name(&i.attrs[..], "plugin_registrar") {
|
||||
if attr::contains_name(&i.attrs[..], sym::plugin_registrar) {
|
||||
gate_feature_post!(&self, plugin_registrar, i.span,
|
||||
"compiler plugins are experimental and possibly buggy");
|
||||
}
|
||||
if attr::contains_name(&i.attrs[..], "start") {
|
||||
if attr::contains_name(&i.attrs[..], sym::start) {
|
||||
gate_feature_post!(&self, start, i.span,
|
||||
"a #[start] function is an experimental \
|
||||
feature whose signature may change \
|
||||
over time");
|
||||
}
|
||||
if attr::contains_name(&i.attrs[..], "main") {
|
||||
if attr::contains_name(&i.attrs[..], sym::main) {
|
||||
gate_feature_post!(&self, main, i.span,
|
||||
"declaration of a nonstandard #[main] \
|
||||
function may change over time, for now \
|
||||
|
|
@ -1976,7 +1977,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||
}
|
||||
|
||||
ast::ItemKind::Struct(..) => {
|
||||
for attr in attr::filter_by_name(&i.attrs[..], "repr") {
|
||||
for attr in attr::filter_by_name(&i.attrs[..], sym::repr) {
|
||||
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
|
||||
if item.check_name(sym::simd) {
|
||||
gate_feature_post!(&self, repr_simd, attr.span,
|
||||
|
|
@ -1987,7 +1988,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||
}
|
||||
|
||||
ast::ItemKind::Enum(..) => {
|
||||
for attr in attr::filter_by_name(&i.attrs[..], "repr") {
|
||||
for attr in attr::filter_by_name(&i.attrs[..], sym::repr) {
|
||||
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
|
||||
if item.check_name(sym::align) {
|
||||
gate_feature_post!(&self, repr_align_enum, attr.span,
|
||||
|
|
@ -2051,7 +2052,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||
match i.node {
|
||||
ast::ForeignItemKind::Fn(..) |
|
||||
ast::ForeignItemKind::Static(..) => {
|
||||
let link_name = attr::first_attr_value_str_by_name(&i.attrs, "link_name");
|
||||
let link_name = attr::first_attr_value_str_by_name(&i.attrs, sym::link_name);
|
||||
let links_to_llvm = match link_name {
|
||||
Some(val) => val.as_str().starts_with("llvm."),
|
||||
_ => false
|
||||
|
|
@ -2311,7 +2312,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
|
|||
if let Some(f_edition) = f_edition {
|
||||
if f_edition <= crate_edition {
|
||||
set(&mut features, DUMMY_SP);
|
||||
edition_enabled_features.insert(Symbol::intern(name), crate_edition);
|
||||
edition_enabled_features.insert(name, crate_edition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2355,7 +2356,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
|
|||
// FIXME(Manishearth) there is currently no way to set
|
||||
// lib features by edition
|
||||
set(&mut features, DUMMY_SP);
|
||||
edition_enabled_features.insert(Symbol::intern(name), *edition);
|
||||
edition_enabled_features.insert(name, *edition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2438,7 +2439,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
|
|||
pub fn check_crate(krate: &ast::Crate,
|
||||
sess: &ParseSess,
|
||||
features: &Features,
|
||||
plugin_attributes: &[(String, AttributeType)],
|
||||
plugin_attributes: &[(Symbol, AttributeType)],
|
||||
unstable: UnstableFeatures) {
|
||||
maybe_stage_features(&sess.span_diagnostic, krate, unstable);
|
||||
let ctx = Context {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue