Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 30a18c2

Browse files
committedOct 4, 2013
auto merge of #9703 : alexcrichton/rust/compiler-features, r=cmr
This implements the necessary logic for gating particular features off by default in the compiler. There are a number of issues which have been wanting this form of mechanism, and this initially gates features which we have open issues for. Additionally, this should unblock #9255
2 parents 3f32898 + 353f77b commit 30a18c2

File tree

107 files changed

+471
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+471
-43
lines changed
 

‎doc/rust.md

+52
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,58 @@ fn main() {
18321832
> individual functions, structs, methods and enum variants, *not* to
18331833
> entire modules, traits, impls or enums themselves.
18341834
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+
18351887
# Statements and expressions
18361888

18371889
Rust is _primarily_ an expression language. This means that most forms of

‎doc/tutorial.md

+8
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,10 @@ fn area(sh: Shape) -> f64 {
746746
}
747747
~~~~
748748

749+
> ***Note:*** This feature of the compiler is currently gated behind the
750+
> `#[feature(struct_variant)]` directive. More about these directives can be
751+
> found in the manual.
752+
749753
## Tuples
750754

751755
Tuples in Rust behave exactly like structs, except that their fields
@@ -2665,6 +2669,10 @@ use farm::*;
26652669
# fn main() { cow(); chicken() }
26662670
~~~
26672671

2672+
> ***Note:*** This feature of the compiler is currently gated behind the
2673+
> `#[feature(globs)]` directive. More about these directives can be found in
2674+
> the manual.
2675+
26682676
However, that's not all. You can also rename an item while you're bringing it into scope:
26692677

26702678
~~~

0 commit comments

Comments
 (0)
Please sign in to comment.