Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #[allow_internal_unstable] to track stability for macros better. #22899

Merged
merged 4 commits into from
Mar 6, 2015

Commits on Mar 5, 2015

  1. 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.
    huonw committed Mar 5, 2015
    Configuration menu
    Copy the full SHA
    84b060c View commit details
    Browse the repository at this point in the history
  2. Use #[allow_internal_unstable] for thread_local!

    This destabilises all the implementation details of `thread_local!`,
    since they do not *need* to be stable with the new attribute.
    huonw committed Mar 5, 2015
    Configuration menu
    Copy the full SHA
    ab7ef74 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    10426f6 View commit details
    Browse the repository at this point in the history
  4. Run feature-gating on the final AST passed to the compiler.

    This ensures we catch everything; previously, an unknown attribute
    inserted by #[cfg_attr(...)] in a macro expansion would not be detected.
    huonw committed Mar 5, 2015
    Configuration menu
    Copy the full SHA
    b5c6ab2 View commit details
    Browse the repository at this point in the history