about summary refs log tree commit diff
path: root/src/doc/reference.md
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2015-03-01 14:09:28 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2015-03-06 00:18:28 +1100
commit84b060ce29bf7dd65fc23e855ad7c5a8748d806c (patch)
tree2d518fd4340c80dc8613a93bffcfee7c264fc0f4 /src/doc/reference.md
parent68740b405404a3f885e388c8d31722797d519c30 (diff)
downloadrust-84b060ce29bf7dd65fc23e855ad7c5a8748d806c.tar.gz
rust-84b060ce29bf7dd65fc23e855ad7c5a8748d806c.zip
Add #[allow_internal_unstable] to track stability for macros better.
Unstable items used in a macro expansion will now always trigger
stability warnings, *unless* the unstable items are directly inside a
macro marked with `#[allow_internal_unstable]`. IOW, the compiler warns
unless the span of the unstable item is a subspan of the definition of a
macro marked with that attribute.

E.g.

    #[allow_internal_unstable]
    macro_rules! foo {
        ($e: expr) => {{
            $e;
            unstable(); // no warning
            only_called_by_foo!();
        }}
    }

    macro_rules! only_called_by_foo {
        () => { unstable() } // warning
    }

    foo!(unstable()) // warning

The unstable inside `foo` is fine, due to the attribute. But the
`unstable` inside `only_called_by_foo` is not, since that macro doesn't
have the attribute, and the `unstable` passed into `foo` is also not
fine since it isn't contained in the macro itself (that is, even though
it is only used directly in the macro).

In the process this makes the stability tracking much more precise,
e.g. previously `println!("{}", unstable())` got no warning, but now it
does. As such, this is a bug fix that may cause [breaking-change]s.

The attribute is definitely feature gated, since it explicitly allows
side-stepping the feature gating system.
Diffstat (limited to 'src/doc/reference.md')
-rw-r--r--src/doc/reference.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md
index fa4986816aa..95ccc71532a 100644
--- a/src/doc/reference.md
+++ b/src/doc/reference.md
@@ -2555,6 +2555,14 @@ The currently implemented features of the reference compiler are:
                             types, e.g. as the return type of a public function.
                             This capability may be removed in the future.
 
+* `allow_internal_unstable` - Allows `macro_rules!` macros to be tagged with the
+                              `#[allow_internal_unstable]` attribute, designed
+                              to allow `std` macros to call
+                              `#[unstable]`/feature-gated functionality
+                              internally without imposing on callers
+                              (i.e. making them behave like function calls in
+                              terms of encapsulation).
+
 If a feature is promoted to a language feature, then all existing programs will
 start to receive compilation warnings about #[feature] directives which enabled
 the new feature (because the directive is no longer necessary). However, if a