Fix a bug introduced in previous commit
This commit is contained in:
@@ -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
|
/// This function is used to print error messages, so it takes extra
|
||||||
/// care to avoid causing a panic when `local_stream` is unusable.
|
/// care to avoid causing a panic when `local_stream` is unusable.
|
||||||
/// For instance, if the TLS key for the local stream is uninitialized
|
/// For instance, if the TLS key for the local stream is
|
||||||
/// or already destroyed, or if the local stream is locked by another
|
/// already destroyed, or if the local stream is locked by another
|
||||||
/// thread, it will just fall back to the global stream.
|
/// thread, it will just fall back to the global stream.
|
||||||
///
|
///
|
||||||
/// However, if the actual I/O causes an error, this function does panic.
|
/// However, if the actual I/O causes an error, this function does panic.
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ impl<T: 'static> LocalKey<T> {
|
|||||||
///
|
///
|
||||||
/// This will lazily initialize the value if this thread has not referenced
|
/// 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
|
/// 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
|
/// # Panics
|
||||||
///
|
///
|
||||||
@@ -484,11 +484,7 @@ mod tests {
|
|||||||
assert!(FOO.try_with(|_| ()).is_err());
|
assert!(FOO.try_with(|_| ()).is_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn foo() -> Foo {
|
thread_local!(static FOO: Foo = Foo);
|
||||||
assert!(FOO.try_with(|_| ()).is_err());
|
|
||||||
Foo
|
|
||||||
}
|
|
||||||
thread_local!(static FOO: Foo = foo());
|
|
||||||
|
|
||||||
thread::spawn(|| {
|
thread::spawn(|| {
|
||||||
assert!(FOO.try_with(|_| ()).is_ok());
|
assert!(FOO.try_with(|_| ()).is_ok());
|
||||||
@@ -520,6 +516,7 @@ mod tests {
|
|||||||
impl Drop for S1 {
|
impl Drop for S1 {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
HITS += 1;
|
||||||
if K2.try_with(|_| ()).is_err() {
|
if K2.try_with(|_| ()).is_err() {
|
||||||
assert_eq!(HITS, 3);
|
assert_eq!(HITS, 3);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user