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.
This commit is contained in:
parent
84b060ce29
commit
ab7ef7402b
@ -125,6 +125,7 @@
|
||||
#![feature(hash)]
|
||||
#![feature(int_uint)]
|
||||
#![feature(unique)]
|
||||
#![feature(allow_internal_unstable)]
|
||||
#![cfg_attr(test, feature(test, rustc_private))]
|
||||
|
||||
// Don't link to std. We are std.
|
||||
|
@ -55,6 +55,7 @@
|
||||
//! ```
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
#![unstable(feature = "thread_local_internals")]
|
||||
|
||||
use prelude::v1::*;
|
||||
|
||||
@ -84,17 +85,14 @@ use sys::thread_local as imp;
|
||||
/// KEY.set(1 as *mut u8);
|
||||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct StaticKey {
|
||||
/// Inner static TLS key (internals), created with by `INIT_INNER` in this
|
||||
/// module.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub inner: StaticKeyInner,
|
||||
/// Destructor for the TLS value.
|
||||
///
|
||||
/// See `Key::new` for information about when the destructor runs and how
|
||||
/// it runs.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub dtor: Option<unsafe extern fn(*mut u8)>,
|
||||
}
|
||||
|
||||
@ -131,7 +129,6 @@ pub struct Key {
|
||||
/// Constant initialization value for static TLS keys.
|
||||
///
|
||||
/// This value specifies no destructor by default.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const INIT: StaticKey = StaticKey {
|
||||
inner: INIT_INNER,
|
||||
dtor: None,
|
||||
@ -140,7 +137,6 @@ pub const INIT: StaticKey = StaticKey {
|
||||
/// Constant initialization value for the inner part of static TLS keys.
|
||||
///
|
||||
/// This value allows specific configuration of the destructor for a TLS key.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const INIT_INNER: StaticKeyInner = StaticKeyInner {
|
||||
key: atomic::ATOMIC_USIZE_INIT,
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ pub mod scoped;
|
||||
|
||||
// Sure wish we had macro hygiene, no?
|
||||
#[doc(hidden)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub mod __impl {
|
||||
pub use super::imp::Key as KeyInner;
|
||||
pub use super::imp::destroy_value;
|
||||
@ -117,6 +117,7 @@ pub struct Key<T> {
|
||||
/// Declare a new thread local storage key of type `std::thread_local::Key`.
|
||||
#[macro_export]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[allow_internal_unstable]
|
||||
macro_rules! thread_local {
|
||||
(static $name:ident: $t:ty = $init:expr) => (
|
||||
static $name: ::std::thread_local::Key<$t> = {
|
||||
@ -176,6 +177,7 @@ macro_rules! thread_local {
|
||||
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[allow_internal_unstable]
|
||||
macro_rules! __thread_local_inner {
|
||||
(static $name:ident: $t:ty = $init:expr) => (
|
||||
#[cfg_attr(all(any(target_os = "macos", target_os = "linux"),
|
||||
@ -337,7 +339,7 @@ mod imp {
|
||||
use ptr;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[stable(since = "1.0.0", feature = "rust1")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub struct Key<T> {
|
||||
// Place the inner bits in an `UnsafeCell` to currently get around the
|
||||
// "only Sync statics" restriction. This allows any type to be placed in
|
||||
@ -345,14 +347,14 @@ mod imp {
|
||||
//
|
||||
// Note that all access requires `T: 'static` so it can't be a type with
|
||||
// any borrowed pointers still.
|
||||
#[stable(since = "1.0.0", feature = "rust1")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub inner: UnsafeCell<T>,
|
||||
|
||||
// Metadata to keep track of the state of the destructor. Remember that
|
||||
// these variables are thread-local, not global.
|
||||
#[stable(since = "1.0.0", feature = "rust1")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub dtor_registered: UnsafeCell<bool>, // should be Cell
|
||||
#[stable(since = "1.0.0", feature = "rust1")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub dtor_running: UnsafeCell<bool>, // should be Cell
|
||||
}
|
||||
|
||||
@ -455,7 +457,7 @@ mod imp {
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub unsafe extern fn destroy_value<T>(ptr: *mut u8) {
|
||||
let ptr = ptr as *mut Key<T>;
|
||||
// Right before we run the user destructor be sure to flag the
|
||||
@ -477,15 +479,15 @@ mod imp {
|
||||
use sys_common::thread_local::StaticKey as OsStaticKey;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[stable(since = "1.0.0", feature = "rust1")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub struct Key<T> {
|
||||
// Statically allocated initialization expression, using an `UnsafeCell`
|
||||
// for the same reasons as above.
|
||||
#[stable(since = "1.0.0", feature = "rust1")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub inner: UnsafeCell<T>,
|
||||
|
||||
// OS-TLS key that we'll use to key off.
|
||||
#[stable(since = "1.0.0", feature = "rust1")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub os: OsStaticKey,
|
||||
}
|
||||
|
||||
@ -528,7 +530,7 @@ mod imp {
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[unstable(feature = "thread_local_internals")]
|
||||
pub unsafe extern fn destroy_value<T: 'static>(ptr: *mut u8) {
|
||||
// The OS TLS ensures that this key contains a NULL value when this
|
||||
// destructor starts to run. We set it back to a sentinel value of 1 to
|
||||
|
@ -65,6 +65,7 @@ pub struct Key<T> { #[doc(hidden)] pub inner: __impl::KeyInner<T> }
|
||||
/// This macro declares a `static` item on which methods are used to get and
|
||||
/// set the value stored within.
|
||||
#[macro_export]
|
||||
#[allow_internal_unstable]
|
||||
macro_rules! scoped_thread_local {
|
||||
(static $name:ident: $t:ty) => (
|
||||
__scoped_thread_local_inner!(static $name: $t);
|
||||
@ -76,6 +77,7 @@ macro_rules! scoped_thread_local {
|
||||
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
#[allow_internal_unstable]
|
||||
macro_rules! __scoped_thread_local_inner {
|
||||
(static $name:ident: $t:ty) => (
|
||||
#[cfg_attr(not(any(windows,
|
||||
|
23
src/test/compile-fail/internal-unstable-thread-local.rs
Normal file
23
src/test/compile-fail/internal-unstable-thread-local.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:internal_unstable.rs
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
extern crate internal_unstable;
|
||||
|
||||
|
||||
thread_local!(static FOO: () = ());
|
||||
thread_local!(static BAR: () = internal_unstable::unstable()); //~ WARN use of unstable
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {} //~ ERROR
|
Loading…
x
Reference in New Issue
Block a user