about summary refs log tree commit diff
path: root/src/test/ui/allocator/auxiliary
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-27 01:33:01 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-27 18:56:16 +0300
commit9be35f82c1abf2ecbab489bca9eca138ea648312 (patch)
tree69888506e34af447d9748c0d542de3ba1dd76210 /src/test/ui/allocator/auxiliary
parentca9faa52f5ada0054b1fa27d97aedf448afb059b (diff)
downloadrust-9be35f82c1abf2ecbab489bca9eca138ea648312.tar.gz
rust-9be35f82c1abf2ecbab489bca9eca138ea648312.zip
tests: Move run-pass tests without naming conflicts to ui
Diffstat (limited to 'src/test/ui/allocator/auxiliary')
-rw-r--r--src/test/ui/allocator/auxiliary/custom-as-global.rs16
-rw-r--r--src/test/ui/allocator/auxiliary/custom.rs21
-rw-r--r--src/test/ui/allocator/auxiliary/helper.rs9
3 files changed, 46 insertions, 0 deletions
diff --git a/src/test/ui/allocator/auxiliary/custom-as-global.rs b/src/test/ui/allocator/auxiliary/custom-as-global.rs
new file mode 100644
index 00000000000..a5e96e77501
--- /dev/null
+++ b/src/test/ui/allocator/auxiliary/custom-as-global.rs
@@ -0,0 +1,16 @@
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+
+extern crate custom;
+
+use std::sync::atomic::{AtomicUsize, Ordering};
+
+use custom::A;
+
+#[global_allocator]
+static ALLOCATOR: A = A(AtomicUsize::new(0));
+
+pub fn get() -> usize {
+    ALLOCATOR.0.load(Ordering::SeqCst)
+}
diff --git a/src/test/ui/allocator/auxiliary/custom.rs b/src/test/ui/allocator/auxiliary/custom.rs
new file mode 100644
index 00000000000..b0ec9ab0929
--- /dev/null
+++ b/src/test/ui/allocator/auxiliary/custom.rs
@@ -0,0 +1,21 @@
+// no-prefer-dynamic
+
+#![feature(allocator_api)]
+#![crate_type = "rlib"]
+
+use std::alloc::{GlobalAlloc, System, Layout};
+use std::sync::atomic::{AtomicUsize, Ordering};
+
+pub struct A(pub AtomicUsize);
+
+unsafe impl GlobalAlloc for A {
+    unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
+        self.0.fetch_add(1, Ordering::SeqCst);
+        System.alloc(layout)
+    }
+
+    unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
+        self.0.fetch_add(1, Ordering::SeqCst);
+        System.dealloc(ptr, layout)
+    }
+}
diff --git a/src/test/ui/allocator/auxiliary/helper.rs b/src/test/ui/allocator/auxiliary/helper.rs
new file mode 100644
index 00000000000..7f6770c226a
--- /dev/null
+++ b/src/test/ui/allocator/auxiliary/helper.rs
@@ -0,0 +1,9 @@
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+
+use std::fmt;
+
+pub fn work_with(p: &fmt::Debug) {
+    drop(p);
+}