]> git.lizzy.rs Git - rust.git/blob - src/test/ui/logging-only-prints-once.rs
Merge commit 'e36a20c24f35a4cee82bbdc600289104c9237c22' into ra-sync-and-pms-component
[rust.git] / src / test / ui / logging-only-prints-once.rs
1 // run-pass
2 // ignore-windows
3 // ignore-emscripten no threads support
4
5 use std::cell::Cell;
6 use std::fmt;
7 use std::thread;
8
9 struct Foo(Cell<isize>);
10
11 impl fmt::Debug for Foo {
12     fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result {
13         let Foo(ref f) = *self;
14         assert_eq!(f.get(), 0);
15         f.set(1);
16         Ok(())
17     }
18 }
19
20 pub fn main() {
21     thread::spawn(move || {
22         let mut f = Foo(Cell::new(0));
23         println!("{:?}", f);
24         let Foo(ref mut f) = f;
25         assert_eq!(f.get(), 1);
26     })
27     .join()
28     .ok()
29     .unwrap();
30 }