1 // run-pass 2 // no-prefer-dynamic 3 // aux-build:custom.rs 4 // aux-build:helper.rs 5 6 extern crate custom; 7 extern crate helper; 8 9 use custom::A; 10 use std::sync::atomic::{AtomicUsize, Ordering}; 11 main()12fn main() { 13 #[global_allocator] 14 pub static GLOBAL: A = A(AtomicUsize::new(0)); 15 16 let n = GLOBAL.0.load(Ordering::SeqCst); 17 let s = Box::new(0); 18 helper::work_with(&s); 19 assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 1); 20 drop(s); 21 assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); 22 } 23