Skip to content

Commit 9971018

Browse files
committed
std test: better type name, clarifying comment
1 parent c54c8cb commit 9971018

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

library/std/src/sync/mutex/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn test_mutex_arc_poison() {
181181
let arc2 = arc.clone();
182182
let _ = thread::spawn(move || {
183183
let lock = arc2.lock().unwrap();
184-
assert_eq!(*lock, 2);
184+
assert_eq!(*lock, 2); // deliberate assertion failure to poison the mutex
185185
})
186186
.join();
187187
assert!(arc.lock().is_err());

library/std/src/thread/local/tests.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ impl Signal {
2323
}
2424
}
2525

26-
struct Foo(Signal);
26+
struct NotifyOnDrop(Signal);
2727

28-
impl Drop for Foo {
28+
impl Drop for NotifyOnDrop {
2929
fn drop(&mut self) {
30-
let Foo(ref f) = *self;
30+
let NotifyOnDrop(ref f) = *self;
3131
f.notify();
3232
}
3333
}
@@ -82,18 +82,18 @@ fn states() {
8282

8383
#[test]
8484
fn smoke_dtor() {
85-
thread_local!(static FOO: UnsafeCell<Option<Foo>> = UnsafeCell::new(None));
85+
thread_local!(static FOO: UnsafeCell<Option<NotifyOnDrop>> = UnsafeCell::new(None));
8686
run(&FOO);
87-
thread_local!(static FOO2: UnsafeCell<Option<Foo>> = const { UnsafeCell::new(None) });
87+
thread_local!(static FOO2: UnsafeCell<Option<NotifyOnDrop>> = const { UnsafeCell::new(None) });
8888
run(&FOO2);
8989

90-
fn run(key: &'static LocalKey<UnsafeCell<Option<Foo>>>) {
90+
fn run(key: &'static LocalKey<UnsafeCell<Option<NotifyOnDrop>>>) {
9191
let signal = Signal::default();
9292
let signal2 = signal.clone();
9393
let t = thread::spawn(move || unsafe {
9494
let mut signal = Some(signal2);
9595
key.with(|f| {
96-
*f.get() = Some(Foo(signal.take().unwrap()));
96+
*f.get() = Some(NotifyOnDrop(signal.take().unwrap()));
9797
});
9898
});
9999
signal.wait();
@@ -187,13 +187,13 @@ fn self_referential() {
187187
fn dtors_in_dtors_in_dtors() {
188188
struct S1(Signal);
189189
thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell::new(None));
190-
thread_local!(static K2: UnsafeCell<Option<Foo>> = UnsafeCell::new(None));
190+
thread_local!(static K2: UnsafeCell<Option<NotifyOnDrop>> = UnsafeCell::new(None));
191191

192192
impl Drop for S1 {
193193
fn drop(&mut self) {
194194
let S1(ref signal) = *self;
195195
unsafe {
196-
let _ = K2.try_with(|s| *s.get() = Some(Foo(signal.clone())));
196+
let _ = K2.try_with(|s| *s.get() = Some(NotifyOnDrop(signal.clone())));
197197
}
198198
}
199199
}
@@ -211,13 +211,13 @@ fn dtors_in_dtors_in_dtors() {
211211
fn dtors_in_dtors_in_dtors_const_init() {
212212
struct S1(Signal);
213213
thread_local!(static K1: UnsafeCell<Option<S1>> = const { UnsafeCell::new(None) });
214-
thread_local!(static K2: UnsafeCell<Option<Foo>> = const { UnsafeCell::new(None) });
214+
thread_local!(static K2: UnsafeCell<Option<NotifyOnDrop>> = const { UnsafeCell::new(None) });
215215

216216
impl Drop for S1 {
217217
fn drop(&mut self) {
218218
let S1(ref signal) = *self;
219219
unsafe {
220-
let _ = K2.try_with(|s| *s.get() = Some(Foo(signal.clone())));
220+
let _ = K2.try_with(|s| *s.get() = Some(NotifyOnDrop(signal.clone())));
221221
}
222222
}
223223
}

0 commit comments

Comments
 (0)