diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-19 02:51:07 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-24 12:29:45 +0300 |
| commit | bf8fc8adfc76f31a8fb6a4cb0dee02f262bd766a (patch) | |
| tree | a8da70f217469424dbb22c71cc9bdbb3e1a137ff /src/test | |
| parent | 76b1ffaf6c70abd3fa4da2e694dc709116258098 (diff) | |
| download | rust-bf8fc8adfc76f31a8fb6a4cb0dee02f262bd766a.tar.gz rust-bf8fc8adfc76f31a8fb6a4cb0dee02f262bd766a.zip | |
syntax_ext: Improve and simplify code generated by `#[global_allocator]`
Instead of
```
mod allocator_abi { /* methods */ }
```
we now generate
```
const _: () = { /* methods */ }
```
and use `std_path` for paths referring to standard library entities.
This way we no longer need to generate `use` and `extern crate` imports, and `#[global_allocator]` starts working inside unnamed blocks.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/allocator/custom-in-block.rs | 5 | ||||
| -rw-r--r-- | src/test/run-pass/allocator/custom-in-submodule.rs | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/test/run-pass/allocator/custom-in-block.rs b/src/test/run-pass/allocator/custom-in-block.rs index 506154ec601..12813a1fc8b 100644 --- a/src/test/run-pass/allocator/custom-in-block.rs +++ b/src/test/run-pass/allocator/custom-in-block.rs @@ -13,9 +13,10 @@ fn main() { #[global_allocator] pub static GLOBAL: A = A(AtomicUsize::new(0)); + let n = GLOBAL.0.load(Ordering::SeqCst); let s = Box::new(0); helper::work_with(&s); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 1); + assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 1); drop(s); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 2); + assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); } diff --git a/src/test/run-pass/allocator/custom-in-submodule.rs b/src/test/run-pass/allocator/custom-in-submodule.rs index f9c4ad7668b..ea341b1ac14 100644 --- a/src/test/run-pass/allocator/custom-in-submodule.rs +++ b/src/test/run-pass/allocator/custom-in-submodule.rs @@ -17,9 +17,10 @@ mod submodule { } fn main() { + let n = submodule::GLOBAL.0.load(Ordering::SeqCst); let s = Box::new(0); helper::work_with(&s); - assert_eq!(submodule::GLOBAL.0.load(Ordering::SeqCst), 1); + assert_eq!(submodule::GLOBAL.0.load(Ordering::SeqCst), n + 1); drop(s); - assert_eq!(submodule::GLOBAL.0.load(Ordering::SeqCst), 2); + assert_eq!(submodule::GLOBAL.0.load(Ordering::SeqCst), n + 2); } |
