]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_feature/src/accepted.rs
e8642a52749c46201ee0e1c7116fd919c33e32e1
[rust.git] / compiler / rustc_feature / src / accepted.rs
1 //! List of the accepted feature gates.
2
3 use super::{to_nonzero, Feature, State};
4 use rustc_span::symbol::sym;
5
6 macro_rules! declare_features {
7     ($(
8         $(#[doc = $doc:tt])* (accepted, $feature:ident, $ver:expr, $issue:expr, None),
9     )+) => {
10         /// Those language feature has since been Accepted (it was once Active)
11         pub const ACCEPTED_FEATURES: &[Feature] = &[
12             $(
13                 Feature {
14                     state: State::Accepted,
15                     name: sym::$feature,
16                     since: $ver,
17                     issue: to_nonzero($issue),
18                     edition: None,
19                     description: concat!($($doc,)*),
20                 }
21             ),+
22         ];
23     }
24 }
25
26 #[rustfmt::skip]
27 declare_features! (
28     // -------------------------------------------------------------------------
29     // feature-group-start: for testing purposes
30     // -------------------------------------------------------------------------
31
32     /// A temporary feature gate used to enable parser extensions needed
33     /// to bootstrap fix for #5723.
34     (accepted, issue_5723_bootstrap, "1.0.0", None, None),
35     /// These are used to test this portion of the compiler,
36     /// they don't actually mean anything.
37     (accepted, test_accepted_feature, "1.0.0", None, None),
38
39     // -------------------------------------------------------------------------
40     // feature-group-end: for testing purposes
41     // -------------------------------------------------------------------------
42
43     // -------------------------------------------------------------------------
44     // feature-group-start: accepted features
45     // -------------------------------------------------------------------------
46
47     /// Allows using associated `type`s in `trait`s.
48     (accepted, associated_types, "1.0.0", None, None),
49     /// Allows using assigning a default type to type parameters in algebraic data type definitions.
50     (accepted, default_type_params, "1.0.0", None, None),
51     // FIXME: explain `globs`.
52     (accepted, globs, "1.0.0", None, None),
53     /// Allows `macro_rules!` items.
54     (accepted, macro_rules, "1.0.0", None, None),
55     /// Allows use of `&foo[a..b]` as a slicing syntax.
56     (accepted, slicing_syntax, "1.0.0", None, None),
57     /// Allows struct variants `Foo { baz: u8, .. }` in enums (RFC 418).
58     (accepted, struct_variant, "1.0.0", None, None),
59     /// Allows indexing tuples.
60     (accepted, tuple_indexing, "1.0.0", None, None),
61     /// Allows the use of `if let` expressions.
62     (accepted, if_let, "1.0.0", None, None),
63     /// Allows the use of `while let` expressions.
64     (accepted, while_let, "1.0.0", None, None),
65     /// Allows using `#![no_std]`.
66     (accepted, no_std, "1.6.0", None, None),
67     /// Allows overloading augmented assignment operations like `a += b`.
68     (accepted, augmented_assignments, "1.8.0", Some(28235), None),
69     /// Allows empty structs and enum variants with braces.
70     (accepted, braced_empty_structs, "1.8.0", Some(29720), None),
71     /// Allows `#[deprecated]` attribute.
72     (accepted, deprecated, "1.9.0", Some(29935), None),
73     /// Allows macros to appear in the type position.
74     (accepted, type_macros, "1.13.0", Some(27245), None),
75     /// Allows use of the postfix `?` operator in expressions.
76     (accepted, question_mark, "1.13.0", Some(31436), None),
77     /// Allows `..` in tuple (struct) patterns.
78     (accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627), None),
79     /// Allows some increased flexibility in the name resolution rules,
80     /// especially around globs and shadowing (RFC 1560).
81     (accepted, item_like_imports, "1.15.0", Some(35120), None),
82     /// Allows using `Self` and associated types in struct expressions and patterns.
83     (accepted, more_struct_aliases, "1.16.0", Some(37544), None),
84     /// Allows elision of `'static` lifetimes in `static`s and `const`s.
85     (accepted, static_in_const, "1.17.0", Some(35897), None),
86     /// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions.
87     (accepted, field_init_shorthand, "1.17.0", Some(37340), None),
88     /// Allows the definition recursive static items.
89     (accepted, static_recursion, "1.17.0", Some(29719), None),
90     /// Allows `pub(restricted)` visibilities (RFC 1422).
91     (accepted, pub_restricted, "1.18.0", Some(32409), None),
92     /// Allows `#![windows_subsystem]`.
93     (accepted, windows_subsystem, "1.18.0", Some(37499), None),
94     /// Allows `break {expr}` with a value inside `loop`s.
95     (accepted, loop_break_value, "1.19.0", Some(37339), None),
96     /// Allows numeric fields in struct expressions and patterns.
97     (accepted, relaxed_adts, "1.19.0", Some(35626), None),
98     /// Allows coercing non capturing closures to function pointers.
99     (accepted, closure_to_fn_coercion, "1.19.0", Some(39817), None),
100     /// Allows attributes on struct literal fields.
101     (accepted, struct_field_attributes, "1.20.0", Some(38814), None),
102     /// Allows the definition of associated constants in `trait` or `impl` blocks.
103     (accepted, associated_consts, "1.20.0", Some(29646), None),
104     /// Allows usage of the `compile_error!` macro.
105     (accepted, compile_error, "1.20.0", Some(40872), None),
106     /// Allows code like `let x: &'static u32 = &42` to work (RFC 1414).
107     (accepted, rvalue_static_promotion, "1.21.0", Some(38865), None),
108     /// Allows `Drop` types in constants (RFC 1440).
109     (accepted, drop_types_in_const, "1.22.0", Some(33156), None),
110     /// Allows the sysV64 ABI to be specified on all platforms
111     /// instead of just the platforms on which it is the C ABI.
112     (accepted, abi_sysv64, "1.24.0", Some(36167), None),
113     /// Allows `repr(align(16))` struct attribute (RFC 1358).
114     (accepted, repr_align, "1.25.0", Some(33626), None),
115     /// Allows '|' at beginning of match arms (RFC 1925).
116     (accepted, match_beginning_vert, "1.25.0", Some(44101), None),
117     /// Allows nested groups in `use` items (RFC 2128).
118     (accepted, use_nested_groups, "1.25.0", Some(44494), None),
119     /// Allows indexing into constant arrays.
120     (accepted, const_indexing, "1.26.0", Some(29947), None),
121     /// Allows using `a..=b` and `..=b` as inclusive range syntaxes.
122     (accepted, inclusive_range_syntax, "1.26.0", Some(28237), None),
123     /// Allows `..=` in patterns (RFC 1192).
124     (accepted, dotdoteq_in_patterns, "1.26.0", Some(28237), None),
125     /// Allows `fn main()` with return types which implements `Termination` (RFC 1937).
126     (accepted, termination_trait, "1.26.0", Some(43301), None),
127     /// Allows implementing `Clone` for closures where possible (RFC 2132).
128     (accepted, clone_closures, "1.26.0", Some(44490), None),
129     /// Allows implementing `Copy` for closures where possible (RFC 2132).
130     (accepted, copy_closures, "1.26.0", Some(44490), None),
131     /// Allows `impl Trait` in function arguments.
132     (accepted, universal_impl_trait, "1.26.0", Some(34511), None),
133     /// Allows `impl Trait` in function return types.
134     (accepted, conservative_impl_trait, "1.26.0", Some(34511), None),
135     /// Allows using the `u128` and `i128` types.
136     (accepted, i128_type, "1.26.0", Some(35118), None),
137     /// Allows default match binding modes (RFC 2005).
138     (accepted, match_default_bindings, "1.26.0", Some(42640), None),
139     /// Allows `'_` placeholder lifetimes.
140     (accepted, underscore_lifetimes, "1.26.0", Some(44524), None),
141     /// Allows attributes on lifetime/type formal parameters in generics (RFC 1327).
142     (accepted, generic_param_attrs, "1.27.0", Some(48848), None),
143     /// Allows `cfg(target_feature = "...")`.
144     (accepted, cfg_target_feature, "1.27.0", Some(29717), None),
145     /// Allows `#[target_feature(...)]`.
146     (accepted, target_feature, "1.27.0", None, None),
147     /// Allows using `dyn Trait` as a syntax for trait objects.
148     (accepted, dyn_trait, "1.27.0", Some(44662), None),
149     /// Allows `#[must_use]` on functions, and introduces must-use operators (RFC 1940).
150     (accepted, fn_must_use, "1.27.0", Some(43302), None),
151     /// Allows use of the `:lifetime` macro fragment specifier.
152     (accepted, macro_lifetime_matcher, "1.27.0", Some(34303), None),
153     /// Allows `#[test]` functions where the return type implements `Termination` (RFC 1937).
154     (accepted, termination_trait_test, "1.27.0", Some(48854), None),
155     /// Allows the `#[global_allocator]` attribute.
156     (accepted, global_allocator, "1.28.0", Some(27389), None),
157     /// Allows `#[repr(transparent)]` attribute on newtype structs.
158     (accepted, repr_transparent, "1.28.0", Some(43036), None),
159     /// Allows procedural macros in `proc-macro` crates.
160     (accepted, proc_macro, "1.29.0", Some(38356), None),
161     /// Allows `foo.rs` as an alternative to `foo/mod.rs`.
162     (accepted, non_modrs_mods, "1.30.0", Some(44660), None),
163     /// Allows use of the `:vis` macro fragment specifier
164     (accepted, macro_vis_matcher, "1.30.0", Some(41022), None),
165     /// Allows importing and reexporting macros with `use`,
166     /// enables macro modularization in general.
167     (accepted, use_extern_macros, "1.30.0", Some(35896), None),
168     /// Allows keywords to be escaped for use as identifiers.
169     (accepted, raw_identifiers, "1.30.0", Some(48589), None),
170     /// Allows attributes scoped to tools.
171     (accepted, tool_attributes, "1.30.0", Some(44690), None),
172     /// Allows multi-segment paths in attributes and derives.
173     (accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None),
174     /// Allows all literals in attribute lists and values of key-value pairs.
175     (accepted, attr_literals, "1.30.0", Some(34981), None),
176     /// Allows inferring outlives requirements (RFC 2093).
177     (accepted, infer_outlives_requirements, "1.30.0", Some(44493), None),
178     /// Allows annotating functions conforming to `fn(&PanicInfo) -> !` with `#[panic_handler]`.
179     /// This defines the behavior of panics.
180     (accepted, panic_handler, "1.30.0", Some(44489), None),
181     /// Allows `#[used]` to preserve symbols (see llvm.used).
182     (accepted, used, "1.30.0", Some(40289), None),
183     /// Allows `crate` in paths.
184     (accepted, crate_in_paths, "1.30.0", Some(45477), None),
185     /// Allows resolving absolute paths as paths from other crates.
186     (accepted, extern_absolute_paths, "1.30.0", Some(44660), None),
187     /// Allows access to crate names passed via `--extern` through prelude.
188     (accepted, extern_prelude, "1.30.0", Some(44660), None),
189     /// Allows parentheses in patterns.
190     (accepted, pattern_parentheses, "1.31.0", Some(51087), None),
191     /// Allows the definition of `const fn` functions.
192     (accepted, min_const_fn, "1.31.0", Some(53555), None),
193     /// Allows scoped lints.
194     (accepted, tool_lints, "1.31.0", Some(44690), None),
195     /// Allows lifetime elision in `impl` headers. For example:
196     /// + `impl<I:Iterator> Iterator for &mut Iterator`
197     /// + `impl Debug for Foo<'_>`
198     (accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None),
199     /// Allows `extern crate foo as bar;`. This puts `bar` into extern prelude.
200     (accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None),
201     /// Allows use of the `:literal` macro fragment specifier (RFC 1576).
202     (accepted, macro_literal_matcher, "1.32.0", Some(35625), None),
203     /// Allows use of `?` as the Kleene "at most one" operator in macros.
204     (accepted, macro_at_most_once_rep, "1.32.0", Some(48075), None),
205     /// Allows `Self` struct constructor (RFC 2302).
206     (accepted, self_struct_ctor, "1.32.0", Some(51994), None),
207     /// Allows `Self` in type definitions (RFC 2300).
208     (accepted, self_in_typedefs, "1.32.0", Some(49303), None),
209     /// Allows `use x::y;` to search `x` in the current scope.
210     (accepted, uniform_paths, "1.32.0", Some(53130), None),
211     /// Allows integer match exhaustiveness checking (RFC 2591).
212     (accepted, exhaustive_integer_patterns, "1.33.0", Some(50907), None),
213     /// Allows `use path as _;` and `extern crate c as _;`.
214     (accepted, underscore_imports, "1.33.0", Some(48216), None),
215     /// Allows `#[repr(packed(N))]` attribute on structs.
216     (accepted, repr_packed, "1.33.0", Some(33158), None),
217     /// Allows irrefutable patterns in `if let` and `while let` statements (RFC 2086).
218     (accepted, irrefutable_let_patterns, "1.33.0", Some(44495), None),
219     /// Allows calling `const unsafe fn` inside `unsafe` blocks in `const fn` functions.
220     (accepted, min_const_unsafe_fn, "1.33.0", Some(55607), None),
221     /// Allows let bindings, assignments and destructuring in `const` functions and constants.
222     /// As long as control flow is not implemented in const eval, `&&` and `||` may not be used
223     /// at the same time as let bindings.
224     (accepted, const_let, "1.33.0", Some(48821), None),
225     /// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`.
226     (accepted, cfg_attr_multi, "1.33.0", Some(54881), None),
227     /// Allows top level or-patterns (`p | q`) in `if let` and `while let`.
228     (accepted, if_while_or_patterns, "1.33.0", Some(48215), None),
229     /// Allows `cfg(target_vendor = "...")`.
230     (accepted, cfg_target_vendor, "1.33.0", Some(29718), None),
231     /// Allows `extern crate self as foo;`.
232     /// This puts local crate root into extern prelude under name `foo`.
233     (accepted, extern_crate_self, "1.34.0", Some(56409), None),
234     /// Allows arbitrary delimited token streams in non-macro attributes.
235     (accepted, unrestricted_attribute_tokens, "1.34.0", Some(55208), None),
236     /// Allows paths to enum variants on type aliases including `Self`.
237     (accepted, type_alias_enum_variants, "1.37.0", Some(49683), None),
238     /// Allows using `#[repr(align(X))]` on enums with equivalent semantics
239     /// to wrapping an enum in a wrapper struct with `#[repr(align(X))]`.
240     (accepted, repr_align_enum, "1.37.0", Some(57996), None),
241     /// Allows `const _: TYPE = VALUE`.
242     (accepted, underscore_const_names, "1.37.0", Some(54912), None),
243     /// Allows free and inherent `async fn`s, `async` blocks, and `<expr>.await` expressions.
244     (accepted, async_await, "1.39.0", Some(50547), None),
245     /// Allows mixing bind-by-move in patterns and references to those identifiers in guards.
246     (accepted, bind_by_move_pattern_guards, "1.39.0", Some(15287), None),
247     /// Allows attributes in formal function parameters.
248     (accepted, param_attrs, "1.39.0", Some(60406), None),
249     /// Allows macro invocations in `extern {}` blocks.
250     (accepted, macros_in_extern, "1.40.0", Some(49476), None),
251     /// Allows future-proofing enums/structs with the `#[non_exhaustive]` attribute (RFC 2008).
252     (accepted, non_exhaustive, "1.40.0", Some(44109), None),
253     /// Allows calling constructor functions in `const fn`.
254     (accepted, const_constructor, "1.40.0", Some(61456), None),
255     /// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests.
256     (accepted, cfg_doctest, "1.40.0", Some(62210), None),
257     /// Allows relaxing the coherence rules such that
258     /// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
259     (accepted, re_rebalance_coherence, "1.41.0", Some(55437), None),
260     /// Allows #[repr(transparent)] on univariant enums (RFC 2645).
261     (accepted, transparent_enums, "1.42.0", Some(60405), None),
262     /// Allows using subslice patterns, `[a, .., b]` and `[a, xs @ .., b]`.
263     (accepted, slice_patterns, "1.42.0", Some(62254), None),
264     /// Allows the use of `if` and `match` in constants.
265     (accepted, const_if_match, "1.46.0", Some(49146), None),
266     /// Allows the use of `loop` and `while` in constants.
267     (accepted, const_loop, "1.46.0", Some(52000), None),
268     /// Allows `#[track_caller]` to be used which provides
269     /// accurate caller location reporting during panic (RFC 2091).
270     (accepted, track_caller, "1.46.0", Some(47809), None),
271     /// Allows `#[doc(alias = "...")]`.
272     (accepted, doc_alias, "1.48.0", Some(50146), None),
273     /// Allows patterns with concurrent by-move and by-ref bindings.
274     /// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref.
275     (accepted, move_ref_pattern, "1.49.0", Some(68354), None),
276     /// The smallest useful subset of `const_generics`.
277     (accepted, min_const_generics, "1.51.0", Some(74878), None),
278     /// The `unsafe_op_in_unsafe_fn` lint (allowed by default): no longer treat an unsafe function as an unsafe block.
279     (accepted, unsafe_block_in_unsafe_fn, "1.52.0", Some(71668), None),
280     /// Allows the use of or-patterns (e.g., `0 | 1`).
281     (accepted, or_patterns, "1.53.0", Some(54883), None),
282     /// Allows defining identifiers beyond ASCII.
283     (accepted, non_ascii_idents, "1.53.0", Some(55467), None),
284
285     // -------------------------------------------------------------------------
286     // feature-group-end: accepted features
287     // -------------------------------------------------------------------------
288 );