2019-08-20 16:40:53 +00:00
|
|
|
//! List of the accepted feature gates.
|
|
|
|
|
2020-09-17 19:11:22 +00:00
|
|
|
use super::{to_nonzero, Feature, State};
|
2019-12-31 17:15:40 +00:00
|
|
|
use rustc_span::symbol::sym;
|
2019-08-20 16:40:53 +00:00
|
|
|
|
|
|
|
macro_rules! declare_features {
|
2019-08-24 15:47:26 +00:00
|
|
|
($(
|
|
|
|
$(#[doc = $doc:tt])* (accepted, $feature:ident, $ver:expr, $issue:expr, None),
|
|
|
|
)+) => {
|
2019-08-20 16:40:53 +00:00
|
|
|
/// Those language feature has since been Accepted (it was once Active)
|
2019-08-24 15:50:21 +00:00
|
|
|
pub const ACCEPTED_FEATURES: &[Feature] = &[
|
|
|
|
$(
|
|
|
|
Feature {
|
|
|
|
state: State::Accepted,
|
|
|
|
name: sym::$feature,
|
|
|
|
since: $ver,
|
2020-09-17 19:11:22 +00:00
|
|
|
issue: to_nonzero($issue),
|
2019-08-24 15:50:21 +00:00
|
|
|
edition: None,
|
|
|
|
}
|
|
|
|
),+
|
2019-08-20 16:40:53 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-24 22:44:51 +00:00
|
|
|
#[rustfmt::skip]
|
2019-08-20 16:40:53 +00:00
|
|
|
declare_features! (
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// feature-group-start: for testing purposes
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2019-08-24 15:47:26 +00:00
|
|
|
/// A temporary feature gate used to enable parser extensions needed
|
|
|
|
/// to bootstrap fix for #5723.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, issue_5723_bootstrap, "1.0.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// These are used to test this portion of the compiler,
|
|
|
|
/// they don't actually mean anything.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, test_accepted_feature, "1.0.0", None, None),
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// feature-group-end: for testing purposes
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// feature-group-start: accepted features
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows using associated `type`s in `trait`s.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, associated_types, "1.0.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows using assigning a default type to type parameters in algebraic data type definitions.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, default_type_params, "1.0.0", None, None),
|
|
|
|
// FIXME: explain `globs`.
|
|
|
|
(accepted, globs, "1.0.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `macro_rules!` items.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, macro_rules, "1.0.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows use of `&foo[a..b]` as a slicing syntax.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, slicing_syntax, "1.0.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows struct variants `Foo { baz: u8, .. }` in enums (RFC 418).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, struct_variant, "1.0.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows indexing tuples.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, tuple_indexing, "1.0.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows the use of `if let` expressions.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, if_let, "1.0.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows the use of `while let` expressions.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, while_let, "1.0.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows using `#![no_std]`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, no_std, "1.6.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows overloading augmented assignment operations like `a += b`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, augmented_assignments, "1.8.0", Some(28235), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows empty structs and enum variants with braces.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, braced_empty_structs, "1.8.0", Some(29720), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `#[deprecated]` attribute.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, deprecated, "1.9.0", Some(29935), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows macros to appear in the type position.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, type_macros, "1.13.0", Some(27245), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows use of the postfix `?` operator in expressions.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, question_mark, "1.13.0", Some(31436), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `..` in tuple (struct) patterns.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows some increased flexibility in the name resolution rules,
|
|
|
|
/// especially around globs and shadowing (RFC 1560).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, item_like_imports, "1.15.0", Some(35120), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows using `Self` and associated types in struct expressions and patterns.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, more_struct_aliases, "1.16.0", Some(37544), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows elision of `'static` lifetimes in `static`s and `const`s.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, static_in_const, "1.17.0", Some(35897), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, field_init_shorthand, "1.17.0", Some(37340), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows the definition recursive static items.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, static_recursion, "1.17.0", Some(29719), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `pub(restricted)` visibilities (RFC 1422).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, pub_restricted, "1.18.0", Some(32409), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `#![windows_subsystem]`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, windows_subsystem, "1.18.0", Some(37499), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `break {expr}` with a value inside `loop`s.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, loop_break_value, "1.19.0", Some(37339), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows numeric fields in struct expressions and patterns.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, relaxed_adts, "1.19.0", Some(35626), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows coercing non capturing closures to function pointers.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, closure_to_fn_coercion, "1.19.0", Some(39817), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows attributes on struct literal fields.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, struct_field_attributes, "1.20.0", Some(38814), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows the definition of associated constants in `trait` or `impl` blocks.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, associated_consts, "1.20.0", Some(29646), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows usage of the `compile_error!` macro.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, compile_error, "1.20.0", Some(40872), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows code like `let x: &'static u32 = &42` to work (RFC 1414).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, rvalue_static_promotion, "1.21.0", Some(38865), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `Drop` types in constants (RFC 1440).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, drop_types_in_const, "1.22.0", Some(33156), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows the sysV64 ABI to be specified on all platforms
|
|
|
|
/// instead of just the platforms on which it is the C ABI.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, abi_sysv64, "1.24.0", Some(36167), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `repr(align(16))` struct attribute (RFC 1358).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, repr_align, "1.25.0", Some(33626), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows '|' at beginning of match arms (RFC 1925).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, match_beginning_vert, "1.25.0", Some(44101), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows nested groups in `use` items (RFC 2128).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, use_nested_groups, "1.25.0", Some(44494), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows indexing into constant arrays.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, const_indexing, "1.26.0", Some(29947), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows using `a..=b` and `..=b` as inclusive range syntaxes.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, inclusive_range_syntax, "1.26.0", Some(28237), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `..=` in patterns (RFC 1192).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, dotdoteq_in_patterns, "1.26.0", Some(28237), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `fn main()` with return types which implements `Termination` (RFC 1937).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, termination_trait, "1.26.0", Some(43301), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows implementing `Clone` for closures where possible (RFC 2132).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, clone_closures, "1.26.0", Some(44490), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows implementing `Copy` for closures where possible (RFC 2132).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, copy_closures, "1.26.0", Some(44490), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `impl Trait` in function arguments.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, universal_impl_trait, "1.26.0", Some(34511), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `impl Trait` in function return types.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, conservative_impl_trait, "1.26.0", Some(34511), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows using the `u128` and `i128` types.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, i128_type, "1.26.0", Some(35118), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows default match binding modes (RFC 2005).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, match_default_bindings, "1.26.0", Some(42640), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `'_` placeholder lifetimes.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, underscore_lifetimes, "1.26.0", Some(44524), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows attributes on lifetime/type formal parameters in generics (RFC 1327).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, generic_param_attrs, "1.27.0", Some(48848), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `cfg(target_feature = "...")`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, cfg_target_feature, "1.27.0", Some(29717), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `#[target_feature(...)]`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, target_feature, "1.27.0", None, None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows using `dyn Trait` as a syntax for trait objects.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, dyn_trait, "1.27.0", Some(44662), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `#[must_use]` on functions, and introduces must-use operators (RFC 1940).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, fn_must_use, "1.27.0", Some(43302), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows use of the `:lifetime` macro fragment specifier.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, macro_lifetime_matcher, "1.27.0", Some(34303), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `#[test]` functions where the return type implements `Termination` (RFC 1937).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, termination_trait_test, "1.27.0", Some(48854), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows the `#[global_allocator]` attribute.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, global_allocator, "1.28.0", Some(27389), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `#[repr(transparent)]` attribute on newtype structs.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, repr_transparent, "1.28.0", Some(43036), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows procedural macros in `proc-macro` crates.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, proc_macro, "1.29.0", Some(38356), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `foo.rs` as an alternative to `foo/mod.rs`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, non_modrs_mods, "1.30.0", Some(44660), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows use of the `:vis` macro fragment specifier
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, macro_vis_matcher, "1.30.0", Some(41022), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows importing and reexporting macros with `use`,
|
|
|
|
/// enables macro modularization in general.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, use_extern_macros, "1.30.0", Some(35896), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows keywords to be escaped for use as identifiers.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, raw_identifiers, "1.30.0", Some(48589), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows attributes scoped to tools.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, tool_attributes, "1.30.0", Some(44690), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows multi-segment paths in attributes and derives.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows all literals in attribute lists and values of key-value pairs.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, attr_literals, "1.30.0", Some(34981), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows inferring outlives requirements (RFC 2093).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, infer_outlives_requirements, "1.30.0", Some(44493), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows annotating functions conforming to `fn(&PanicInfo) -> !` with `#[panic_handler]`.
|
|
|
|
/// This defines the behavior of panics.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, panic_handler, "1.30.0", Some(44489), None),
|
2021-08-07 15:04:32 +00:00
|
|
|
/// Allows `#[used]` to preserve symbols (see llvm.compiler.used).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, used, "1.30.0", Some(40289), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `crate` in paths.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, crate_in_paths, "1.30.0", Some(45477), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows resolving absolute paths as paths from other crates.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, extern_absolute_paths, "1.30.0", Some(44660), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows access to crate names passed via `--extern` through prelude.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, extern_prelude, "1.30.0", Some(44660), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows parentheses in patterns.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, pattern_parentheses, "1.31.0", Some(51087), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows the definition of `const fn` functions.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, min_const_fn, "1.31.0", Some(53555), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows scoped lints.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, tool_lints, "1.31.0", Some(44690), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows lifetime elision in `impl` headers. For example:
|
|
|
|
/// + `impl<I:Iterator> Iterator for &mut Iterator`
|
|
|
|
/// + `impl Debug for Foo<'_>`
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `extern crate foo as bar;`. This puts `bar` into extern prelude.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows use of the `:literal` macro fragment specifier (RFC 1576).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, macro_literal_matcher, "1.32.0", Some(35625), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows use of `?` as the Kleene "at most one" operator in macros.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, macro_at_most_once_rep, "1.32.0", Some(48075), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `Self` struct constructor (RFC 2302).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, self_struct_ctor, "1.32.0", Some(51994), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `Self` in type definitions (RFC 2300).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, self_in_typedefs, "1.32.0", Some(49303), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `use x::y;` to search `x` in the current scope.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, uniform_paths, "1.32.0", Some(53130), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows integer match exhaustiveness checking (RFC 2591).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, exhaustive_integer_patterns, "1.33.0", Some(50907), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `use path as _;` and `extern crate c as _;`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, underscore_imports, "1.33.0", Some(48216), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `#[repr(packed(N))]` attribute on structs.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, repr_packed, "1.33.0", Some(33158), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows irrefutable patterns in `if let` and `while let` statements (RFC 2086).
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, irrefutable_let_patterns, "1.33.0", Some(44495), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows calling `const unsafe fn` inside `unsafe` blocks in `const fn` functions.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, min_const_unsafe_fn, "1.33.0", Some(55607), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows let bindings, assignments and destructuring in `const` functions and constants.
|
|
|
|
/// As long as control flow is not implemented in const eval, `&&` and `||` may not be used
|
|
|
|
/// at the same time as let bindings.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, const_let, "1.33.0", Some(48821), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, cfg_attr_multi, "1.33.0", Some(54881), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows top level or-patterns (`p | q`) in `if let` and `while let`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, if_while_or_patterns, "1.33.0", Some(48215), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `cfg(target_vendor = "...")`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, cfg_target_vendor, "1.33.0", Some(29718), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `extern crate self as foo;`.
|
|
|
|
/// This puts local crate root into extern prelude under name `foo`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, extern_crate_self, "1.34.0", Some(56409), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows arbitrary delimited token streams in non-macro attributes.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, unrestricted_attribute_tokens, "1.34.0", Some(55208), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows paths to enum variants on type aliases including `Self`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, type_alias_enum_variants, "1.37.0", Some(49683), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows using `#[repr(align(X))]` on enums with equivalent semantics
|
|
|
|
/// to wrapping an enum in a wrapper struct with `#[repr(align(X))]`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, repr_align_enum, "1.37.0", Some(57996), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows `const _: TYPE = VALUE`.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, underscore_const_names, "1.37.0", Some(54912), None),
|
2019-08-24 15:47:26 +00:00
|
|
|
/// Allows free and inherent `async fn`s, `async` blocks, and `<expr>.await` expressions.
|
2019-08-20 16:40:53 +00:00
|
|
|
(accepted, async_await, "1.39.0", Some(50547), None),
|
2019-07-29 21:29:14 +00:00
|
|
|
/// Allows mixing bind-by-move in patterns and references to those identifiers in guards.
|
|
|
|
(accepted, bind_by_move_pattern_guards, "1.39.0", Some(15287), None),
|
2019-08-29 23:44:30 +00:00
|
|
|
/// Allows attributes in formal function parameters.
|
|
|
|
(accepted, param_attrs, "1.39.0", Some(60406), None),
|
2019-09-20 20:09:39 +00:00
|
|
|
/// Allows macro invocations in `extern {}` blocks.
|
2019-08-26 23:07:26 +00:00
|
|
|
(accepted, macros_in_extern, "1.40.0", Some(49476), None),
|
2019-09-20 20:09:39 +00:00
|
|
|
/// Allows future-proofing enums/structs with the `#[non_exhaustive]` attribute (RFC 2008).
|
|
|
|
(accepted, non_exhaustive, "1.40.0", Some(44109), None),
|
2019-10-07 20:08:39 +00:00
|
|
|
/// Allows calling constructor functions in `const fn`.
|
|
|
|
(accepted, const_constructor, "1.40.0", Some(61456), None),
|
2019-08-01 21:18:37 +00:00
|
|
|
/// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests.
|
|
|
|
(accepted, cfg_doctest, "1.40.0", Some(62210), None),
|
2019-10-26 15:28:02 +00:00
|
|
|
/// Allows relaxing the coherence rules such that
|
|
|
|
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
|
2019-11-07 14:20:56 +00:00
|
|
|
(accepted, re_rebalance_coherence, "1.41.0", Some(55437), None),
|
2020-01-10 23:53:54 +00:00
|
|
|
/// Allows #[repr(transparent)] on univariant enums (RFC 2645).
|
|
|
|
(accepted, transparent_enums, "1.42.0", Some(60405), None),
|
2019-12-29 23:16:16 +00:00
|
|
|
/// Allows using subslice patterns, `[a, .., b]` and `[a, xs @ .., b]`.
|
|
|
|
(accepted, slice_patterns, "1.42.0", Some(62254), None),
|
2020-05-21 18:44:45 +00:00
|
|
|
/// Allows the use of `if` and `match` in constants.
|
2020-06-29 18:14:31 +00:00
|
|
|
(accepted, const_if_match, "1.46.0", Some(49146), None),
|
2020-06-26 00:40:06 +00:00
|
|
|
/// Allows the use of `loop` and `while` in constants.
|
2020-06-29 18:14:31 +00:00
|
|
|
(accepted, const_loop, "1.46.0", Some(52000), None),
|
2020-05-21 23:43:39 +00:00
|
|
|
/// Allows `#[track_caller]` to be used which provides
|
|
|
|
/// accurate caller location reporting during panic (RFC 2091).
|
|
|
|
(accepted, track_caller, "1.46.0", Some(47809), None),
|
2020-08-20 11:35:00 +00:00
|
|
|
/// Allows `#[doc(alias = "...")]`.
|
|
|
|
(accepted, doc_alias, "1.48.0", Some(50146), None),
|
2020-08-30 18:59:56 +00:00
|
|
|
/// Allows patterns with concurrent by-move and by-ref bindings.
|
|
|
|
/// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref.
|
2021-03-02 11:54:25 +00:00
|
|
|
(accepted, move_ref_pattern, "1.49.0", Some(68354), None),
|
2021-08-27 16:04:57 +00:00
|
|
|
/// The smallest useful subset of const generics.
|
2020-11-17 09:55:13 +00:00
|
|
|
(accepted, min_const_generics, "1.51.0", Some(74878), None),
|
2020-11-19 17:32:35 +00:00
|
|
|
/// The `unsafe_op_in_unsafe_fn` lint (allowed by default): no longer treat an unsafe function as an unsafe block.
|
2021-04-01 01:56:51 +00:00
|
|
|
(accepted, unsafe_block_in_unsafe_fn, "1.52.0", Some(71668), None),
|
2020-11-21 21:12:05 +00:00
|
|
|
/// Allows the use of or-patterns (e.g., `0 | 1`).
|
|
|
|
(accepted, or_patterns, "1.53.0", Some(54883), None),
|
2021-04-03 02:35:11 +00:00
|
|
|
/// Allows defining identifiers beyond ASCII.
|
|
|
|
(accepted, non_ascii_idents, "1.53.0", Some(55467), None),
|
Stabilize extended_key_value_attributes
# Stabilization report
## Summary
This stabilizes using macro expansion in key-value attributes, like so:
```rust
#[doc = include_str!("my_doc.md")]
struct S;
#[path = concat!(env!("OUT_DIR"), "/generated.rs")]
mod m;
```
See the changes to the reference for details on what macros are allowed;
see Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455)
for alternatives that were considered and rejected ("why accept no more
and no less?")
This has been available on nightly since 1.50 with no major issues.
## Notes
### Accepted syntax
The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`). Note that decorators and the like may be able to observe other expression forms.
### Expansion ordering
Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input.
There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work).
## Test cases
- https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs
- https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs
The feature has also been dogfooded extensively in the compiler and
standard library:
- https://github.com/rust-lang/rust/pull/83329
- https://github.com/rust-lang/rust/pull/83230
- https://github.com/rust-lang/rust/pull/82641
- https://github.com/rust-lang/rust/pull/80534
## Implementation history
- Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412
- Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121
- Preliminary work to restrict expansion that would conflict with this
feature: https://github.com/rust-lang/rust/pull/77271
- Initial implementation: https://github.com/rust-lang/rust/pull/78837
- Fix for an ICE: https://github.com/rust-lang/rust/pull/80563
## Unresolved Questions
~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~
## Additional Information
There are two workarounds that have a similar effect for `#[doc]`
attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons:
```rust
macro_rules! forward_inner_docs {
($e:expr => $i:item) => {
#[doc = $e]
$i
};
}
forward_inner_docs!(include_str!("lib.rs") => struct S {});
```
This also works for other attributes (like `#[path = concat!(...)]`).
The other is to use `doc(include)`:
```rust
#![feature(external_doc)]
#[doc(include = "lib.rs")]
struct S {}
```
The first works, but is non-trivial for people to discover, and
difficult to read and maintain. The second is a strange special-case for
a particular use of the macro. This generalizes it to work for any use
case, not just including files.
I plan to remove `doc(include)` when this is stabilized. The
`forward_inner_docs` workaround will still compile without warnings, but
I expect it to be used less once it's no longer necessary.
2021-03-22 05:10:10 +00:00
|
|
|
/// Allows arbitrary expressions in key-value attributes at parse time.
|
|
|
|
(accepted, extended_key_value_attributes, "1.54.0", Some(78835), None),
|
2021-05-08 14:28:29 +00:00
|
|
|
/// Allows unsizing coercions in `const fn`.
|
|
|
|
(accepted, const_fn_unsize, "1.54.0", Some(64992), None),
|
2021-04-29 14:31:44 +00:00
|
|
|
/// Allows `impl Trait` with multiple unrelated lifetimes.
|
|
|
|
(accepted, member_constraints, "1.54.0", Some(61997), None),
|
2021-05-14 22:52:04 +00:00
|
|
|
/// Allows bindings in the subpattern of a binding pattern.
|
|
|
|
/// For example, you can write `x @ Some(y)`.
|
2021-10-06 16:34:39 +00:00
|
|
|
(accepted, bindings_after_at, "1.56.0", Some(65490), None),
|
2021-06-03 06:11:14 +00:00
|
|
|
/// Allows calling `transmute` in const fn
|
|
|
|
(accepted, const_fn_transmute, "1.56.0", Some(53605), None),
|
2021-06-03 06:16:56 +00:00
|
|
|
/// Allows accessing fields of unions inside `const` functions.
|
|
|
|
(accepted, const_fn_union, "1.56.0", Some(51909), None),
|
2021-07-17 14:50:33 +00:00
|
|
|
/// Allows macro attributes to observe output of `#[derive]`.
|
|
|
|
(accepted, macro_attributes_in_derive_output, "1.57.0", Some(81119), None),
|
2021-10-04 04:33:43 +00:00
|
|
|
/// Allows panicking during const eval (producing compile-time errors).
|
|
|
|
(accepted, const_panic, "1.57.0", Some(51999), None),
|
2021-10-30 13:56:02 +00:00
|
|
|
/// Lessens the requirements for structs to implement `Unsize`.
|
|
|
|
(accepted, relaxed_struct_unsize, "1.58.0", Some(81793), None),
|
2021-10-05 08:55:57 +00:00
|
|
|
/// Allows dereferencing raw pointers during const eval.
|
|
|
|
(accepted, const_raw_ptr_deref, "1.58.0", Some(51911), None),
|
2021-11-01 15:18:36 +00:00
|
|
|
/// Allows capturing variables in scope using format_args!
|
|
|
|
(accepted, format_args_capture, "1.58.0", Some(67984), None),
|
2019-08-20 16:40:53 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// feature-group-end: accepted features
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
);
|