提交 cb56b2d1 编写于 作者: S Stjepan Glavina

Fix a bug introduced in previous commit

上级 082dd6d7
......@@ -663,8 +663,8 @@ pub fn set_print(sink: Option<Box<Write + Send>>) -> Option<Box<Write + Send>> {
///
/// This function is used to print error messages, so it takes extra
/// care to avoid causing a panic when `local_stream` is unusable.
/// For instance, if the TLS key for the local stream is uninitialized
/// or already destroyed, or if the local stream is locked by another
/// For instance, if the TLS key for the local stream is
/// already destroyed, or if the local stream is locked by another
/// thread, it will just fall back to the global stream.
///
/// However, if the actual I/O causes an error, this function does panic.
......
......@@ -272,7 +272,7 @@ unsafe fn init(&self, slot: &UnsafeCell<Option<T>>) -> &T {
///
/// This will lazily initialize the value if this thread has not referenced
/// this key yet. If the key has been destroyed (which may happen if this is called
/// in a destructor), this function will return a ThreadLocalError.
/// in a destructor), this function will return a `ThreadLocalError`.
///
/// # Panics
///
......@@ -484,11 +484,7 @@ fn drop(&mut self) {
assert!(FOO.try_with(|_| ()).is_err());
}
}
fn foo() -> Foo {
assert!(FOO.try_with(|_| ()).is_err());
Foo
}
thread_local!(static FOO: Foo = foo());
thread_local!(static FOO: Foo = Foo);
thread::spawn(|| {
assert!(FOO.try_with(|_| ()).is_ok());
......@@ -520,6 +516,7 @@ fn circular() {
impl Drop for S1 {
fn drop(&mut self) {
unsafe {
HITS += 1;
if K2.try_with(|_| ()).is_err() {
assert_eq!(HITS, 3);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册