Skip to content

Commit cb56b2d

Browse files
author
Stjepan Glavina
committed
Fix a bug introduced in previous commit
1 parent 082dd6d commit cb56b2d

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/libstd/io/stdio.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,8 @@ pub fn set_print(sink: Option<Box<Write + Send>>) -> Option<Box<Write + Send>> {
663663
///
664664
/// This function is used to print error messages, so it takes extra
665665
/// care to avoid causing a panic when `local_stream` is unusable.
666-
/// For instance, if the TLS key for the local stream is uninitialized
667-
/// or already destroyed, or if the local stream is locked by another
666+
/// For instance, if the TLS key for the local stream is
667+
/// already destroyed, or if the local stream is locked by another
668668
/// thread, it will just fall back to the global stream.
669669
///
670670
/// However, if the actual I/O causes an error, this function does panic.

src/libstd/thread/local.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl<T: 'static> LocalKey<T> {
272272
///
273273
/// This will lazily initialize the value if this thread has not referenced
274274
/// this key yet. If the key has been destroyed (which may happen if this is called
275-
/// in a destructor), this function will return a ThreadLocalError.
275+
/// in a destructor), this function will return a `ThreadLocalError`.
276276
///
277277
/// # Panics
278278
///
@@ -484,11 +484,7 @@ mod tests {
484484
assert!(FOO.try_with(|_| ()).is_err());
485485
}
486486
}
487-
fn foo() -> Foo {
488-
assert!(FOO.try_with(|_| ()).is_err());
489-
Foo
490-
}
491-
thread_local!(static FOO: Foo = foo());
487+
thread_local!(static FOO: Foo = Foo);
492488

493489
thread::spawn(|| {
494490
assert!(FOO.try_with(|_| ()).is_ok());
@@ -520,6 +516,7 @@ mod tests {
520516
impl Drop for S1 {
521517
fn drop(&mut self) {
522518
unsafe {
519+
HITS += 1;
523520
if K2.try_with(|_| ()).is_err() {
524521
assert_eq!(HITS, 3);
525522
} else {

0 commit comments

Comments
 (0)