about summary refs log tree commit diff
path: root/src/liballoc/alloc.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-08-02 15:22:50 +0000
committerbors <bors@rust-lang.org>2019-08-02 15:22:50 +0000
commitcf048cc115860cc110865f460f3f2b9b4308ad92 (patch)
tree883bd4b5406aa47155d362bbadfe0b6f3d795793 /src/liballoc/alloc.rs
parent1df512fcaeaf17639c5d28a3045814d6f7a7db97 (diff)
parent62ec2cb7acb1b16d0abd8a2cf40da545a13d29f3 (diff)
downloadrust-cf048cc115860cc110865f460f3f2b9b4308ad92.tar.gz
rust-cf048cc115860cc110865f460f3f2b9b4308ad92.zip
Auto merge of #63207 - petrochenkov:outest2, r=Mark-Simulacrum
Unconfigure compiler unit test files during normal build

I haven't touched libstd though, it had a lot of tests and I'm not sure the people maintaining it want this.

Closes https://github.com/rust-lang/rust/issues/61097
r? @Mark-Simulacrum
Diffstat (limited to 'src/liballoc/alloc.rs')
-rw-r--r--src/liballoc/alloc.rs36
1 files changed, 3 insertions, 33 deletions
diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs
index cef2b5eea34..dc7fd1adc29 100644
--- a/src/liballoc/alloc.rs
+++ b/src/liballoc/alloc.rs
@@ -10,6 +10,9 @@ use core::usize;
 #[doc(inline)]
 pub use core::alloc::*;
 
+#[cfg(test)]
+mod tests;
+
 extern "Rust" {
     // These are the magic symbols to call the global allocator.  rustc generates
     // them from the `#[global_allocator]` attribute if there is one, or uses the
@@ -244,36 +247,3 @@ pub fn handle_alloc_error(layout: Layout) -> ! {
     }
     unsafe { oom_impl(layout) }
 }
-
-#[cfg(test)]
-mod tests {
-    extern crate test;
-    use test::Bencher;
-    use crate::boxed::Box;
-    use crate::alloc::{Global, Alloc, Layout, handle_alloc_error};
-
-    #[test]
-    fn allocate_zeroed() {
-        unsafe {
-            let layout = Layout::from_size_align(1024, 1).unwrap();
-            let ptr = Global.alloc_zeroed(layout.clone())
-                .unwrap_or_else(|_| handle_alloc_error(layout));
-
-            let mut i = ptr.cast::<u8>().as_ptr();
-            let end = i.add(layout.size());
-            while i < end {
-                assert_eq!(*i, 0);
-                i = i.offset(1);
-            }
-            Global.dealloc(ptr, layout);
-        }
-    }
-
-    #[bench]
-    #[cfg(not(miri))] // Miri does not support benchmarks
-    fn alloc_owned_small(b: &mut Bencher) {
-        b.iter(|| {
-            let _: Box<_> = box 10;
-        })
-    }
-}