@@ -1832,6 +1832,58 @@ fn main() {
1832
1832
> individual functions, structs, methods and enum variants, * not* to
1833
1833
> entire modules, traits, impls or enums themselves.
1834
1834
1835
+ ### Compiler Features
1836
+
1837
+ Certain aspects of Rust may be implemented in the compiler, but they're not
1838
+ necessarily ready for every-day use. These features are often of "prototype
1839
+ quality" or "almost production ready", but may not be stable enough to be
1840
+ considered a full-fleged language feature.
1841
+
1842
+ For this reason, rust recognizes a special crate-level attribute of the form:
1843
+
1844
+ ~~~ {.xfail-test}
1845
+ #[feature(feature1, feature2, feature3)]
1846
+ ~~~
1847
+
1848
+ This directive informs the compiler that the feature list: ` feature1 ` ,
1849
+ ` feature2 ` , and ` feature3 ` should all be enabled. This is only recognized at a
1850
+ crate-level, not at a module-level. Without this directive, all features are
1851
+ considered off, and using the features will result in a compiler error.
1852
+
1853
+ The currently implemented features of the compiler are:
1854
+
1855
+ * ` macro_rules ` - The definition of new macros. This does not encompass
1856
+ macro-invocation, that is always enabled by default, this only
1857
+ covers the definition of new macros. There are currently
1858
+ various problems with invoking macros, how they interact with
1859
+ their environment, and possibly how they are used outside of
1860
+ location in which they are defined. Macro definitions are
1861
+ likely to change slightly in the future, so they are currently
1862
+ hidden behind this feature.
1863
+
1864
+ * ` globs ` - Importing everything in a module through ` * ` . This is currently a
1865
+ large source of bugs in name resolution for Rust, and it's not clear
1866
+ whether this will continue as a feature or not. For these reasons,
1867
+ the glob import statement has been hidden behind this feature flag.
1868
+
1869
+ * ` struct_variant ` - Structural enum variants (those with named fields). It is
1870
+ currently unknown whether this style of enum variant is as
1871
+ fully supported as the tuple-forms, and it's not certain
1872
+ that this style of variant should remain in the language.
1873
+ For now this style of variant is hidden behind a feature
1874
+ flag.
1875
+
1876
+ If a feature is promoted to a language feature, then all existing programs will
1877
+ start to receive compilation warnings about #[ feature] directives which enabled
1878
+ the new feature (because the directive is no longer necessary). However, if
1879
+ a feature is decided to be removed from the language, errors will be issued (if
1880
+ there isn't a parser error first). The directive in this case is no longer
1881
+ necessary, and it's likely that existing code will break if the feature isn't
1882
+ removed.
1883
+
1884
+ If a unknown feature is found in a directive, it results in a compiler error. An
1885
+ unknown feature is one which has never been recognized by the compiler.
1886
+
1835
1887
# Statements and expressions
1836
1888
1837
1889
Rust is _ primarily_ an expression language. This means that most forms of
0 commit comments