about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-06-12 00:36:21 +0000
committerbors <bors@rust-lang.org>2018-06-12 00:36:21 +0000
commit4367e41ea2a105c373de27c2f080fc2527cc6927 (patch)
tree9ca30ec2dbf3311f0a0d0d6275d5abca8f23fc1f /src/test
parentf9944fde377b8b2575f96fff60f784eddce54002 (diff)
parent7f0d54d98842c786ab7a140c17c3ea32aea6aead (diff)
downloadrust-4367e41ea2a105c373de27c2f080fc2527cc6927.tar.gz
rust-4367e41ea2a105c373de27c2f080fc2527cc6927.zip
Auto merge of #51241 - glandium:globalalloc, r=sfackler,SimonSapin
Stabilize GlobalAlloc and #[global_allocator]

This PR implements the changes discussed in https://github.com/rust-lang/rust/issues/49668#issuecomment-393263510

Fixes #49668
Fixes #27389

This does not change the default global allocator: #36963
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/allocator/auxiliary/system-allocator.rs1
-rw-r--r--src/test/compile-fail/allocator/auxiliary/system-allocator2.rs1
-rw-r--r--src/test/compile-fail/allocator/function-allocator.rs1
-rw-r--r--src/test/compile-fail/allocator/not-an-allocator.rs2
-rw-r--r--src/test/compile-fail/allocator/two-allocators.rs2
-rw-r--r--src/test/compile-fail/allocator/two-allocators2.rs2
-rw-r--r--src/test/compile-fail/allocator/two-allocators3.rs1
-rw-r--r--src/test/compile-fail/lint-stability-fields.rs7
-rw-r--r--src/test/run-make-fulldeps/std-core-cycle/bar.rs4
-rw-r--r--src/test/run-make-fulldeps/std-core-cycle/foo.rs1
-rw-r--r--src/test/run-pass-valgrind/issue-44800.rs5
-rw-r--r--src/test/run-pass/allocator/auxiliary/custom-as-global.rs1
-rw-r--r--src/test/run-pass/allocator/auxiliary/custom.rs6
-rw-r--r--src/test/run-pass/allocator/custom.rs8
-rw-r--r--src/test/run-pass/allocator/xcrate-use.rs2
-rw-r--r--src/test/run-pass/allocator/xcrate-use2.rs6
-rw-r--r--src/test/run-pass/realloc-16687.rs4
-rw-r--r--src/test/run-pass/thin-lto-global-allocator.rs2
-rw-r--r--src/test/ui/feature-gate-global_allocator.rs14
-rw-r--r--src/test/ui/feature-gate-global_allocator.stderr11
20 files changed, 23 insertions, 58 deletions
diff --git a/src/test/compile-fail/allocator/auxiliary/system-allocator.rs b/src/test/compile-fail/allocator/auxiliary/system-allocator.rs
index 37e64ba7ea1..e5650d5b7b0 100644
--- a/src/test/compile-fail/allocator/auxiliary/system-allocator.rs
+++ b/src/test/compile-fail/allocator/auxiliary/system-allocator.rs
@@ -10,7 +10,6 @@
 
 // no-prefer-dynamic
 
-#![feature(global_allocator, allocator_api)]
 #![crate_type = "rlib"]
 
 use std::alloc::System;
diff --git a/src/test/compile-fail/allocator/auxiliary/system-allocator2.rs b/src/test/compile-fail/allocator/auxiliary/system-allocator2.rs
index 37e64ba7ea1..e5650d5b7b0 100644
--- a/src/test/compile-fail/allocator/auxiliary/system-allocator2.rs
+++ b/src/test/compile-fail/allocator/auxiliary/system-allocator2.rs
@@ -10,7 +10,6 @@
 
 // no-prefer-dynamic
 
-#![feature(global_allocator, allocator_api)]
 #![crate_type = "rlib"]
 
 use std::alloc::System;
diff --git a/src/test/compile-fail/allocator/function-allocator.rs b/src/test/compile-fail/allocator/function-allocator.rs
index 50f82607b53..989c102b86e 100644
--- a/src/test/compile-fail/allocator/function-allocator.rs
+++ b/src/test/compile-fail/allocator/function-allocator.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(global_allocator)]
 
 #[global_allocator]
 fn foo() {} //~ ERROR: allocators must be statics
diff --git a/src/test/compile-fail/allocator/not-an-allocator.rs b/src/test/compile-fail/allocator/not-an-allocator.rs
index 140cad22f34..6559335960a 100644
--- a/src/test/compile-fail/allocator/not-an-allocator.rs
+++ b/src/test/compile-fail/allocator/not-an-allocator.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(global_allocator, heap_api)]
-
 #[global_allocator]
 static A: usize = 0;
 //~^ the trait bound `usize:
diff --git a/src/test/compile-fail/allocator/two-allocators.rs b/src/test/compile-fail/allocator/two-allocators.rs
index 5aa6b5d6777..7a97a11df20 100644
--- a/src/test/compile-fail/allocator/two-allocators.rs
+++ b/src/test/compile-fail/allocator/two-allocators.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(global_allocator, allocator_api)]
-
 use std::alloc::System;
 
 #[global_allocator]
diff --git a/src/test/compile-fail/allocator/two-allocators2.rs b/src/test/compile-fail/allocator/two-allocators2.rs
index ec5d985a943..e747140dfe5 100644
--- a/src/test/compile-fail/allocator/two-allocators2.rs
+++ b/src/test/compile-fail/allocator/two-allocators2.rs
@@ -12,8 +12,6 @@
 // no-prefer-dynamic
 // error-pattern: the #[global_allocator] in
 
-#![feature(global_allocator, allocator_api)]
-
 extern crate system_allocator;
 
 use std::alloc::System;
diff --git a/src/test/compile-fail/allocator/two-allocators3.rs b/src/test/compile-fail/allocator/two-allocators3.rs
index c310d94f6df..dd86b02bd20 100644
--- a/src/test/compile-fail/allocator/two-allocators3.rs
+++ b/src/test/compile-fail/allocator/two-allocators3.rs
@@ -13,7 +13,6 @@
 // no-prefer-dynamic
 // error-pattern: the #[global_allocator] in
 
-#![feature(global_allocator)]
 
 extern crate system_allocator;
 extern crate system_allocator2;
diff --git a/src/test/compile-fail/lint-stability-fields.rs b/src/test/compile-fail/lint-stability-fields.rs
index 1b605bdb893..b1b1a9a1fbf 100644
--- a/src/test/compile-fail/lint-stability-fields.rs
+++ b/src/test/compile-fail/lint-stability-fields.rs
@@ -18,6 +18,11 @@
 mod cross_crate {
     extern crate lint_stability_fields;
 
+    mod reexport {
+        #[stable(feature = "rust1", since = "1.0.0")]
+        pub use super::lint_stability_fields::*;
+    }
+
     use self::lint_stability_fields::*;
 
     pub fn foo() {
@@ -73,6 +78,8 @@ mod cross_crate {
             // the patterns are all fine:
             { .. } = x;
 
+        // Unstable items are still unstable even when used through a stable "pub use".
+        let x = reexport::Unstable2(1, 2, 3); //~ ERROR use of unstable
 
         let x = Unstable2(1, 2, 3); //~ ERROR use of unstable
 
diff --git a/src/test/run-make-fulldeps/std-core-cycle/bar.rs b/src/test/run-make-fulldeps/std-core-cycle/bar.rs
index 62fd2ade1ca..4b885e5e2bb 100644
--- a/src/test/run-make-fulldeps/std-core-cycle/bar.rs
+++ b/src/test/run-make-fulldeps/std-core-cycle/bar.rs
@@ -16,11 +16,11 @@ use std::alloc::*;
 pub struct A;
 
 unsafe impl GlobalAlloc for A {
-    unsafe fn alloc(&self, _: Layout) -> *mut Opaque {
+    unsafe fn alloc(&self, _: Layout) -> *mut u8 {
         loop {}
     }
 
-    unsafe fn dealloc(&self, _ptr: *mut Opaque, _: Layout) {
+    unsafe fn dealloc(&self, _ptr: *mut u8, _: Layout) {
         loop {}
     }
 }
diff --git a/src/test/run-make-fulldeps/std-core-cycle/foo.rs b/src/test/run-make-fulldeps/std-core-cycle/foo.rs
index 04742bba3c8..46047fb835d 100644
--- a/src/test/run-make-fulldeps/std-core-cycle/foo.rs
+++ b/src/test/run-make-fulldeps/std-core-cycle/foo.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(global_allocator)]
 #![crate_type = "cdylib"]
 
 extern crate bar;
diff --git a/src/test/run-pass-valgrind/issue-44800.rs b/src/test/run-pass-valgrind/issue-44800.rs
index cfde6f32f66..29cfae16929 100644
--- a/src/test/run-pass-valgrind/issue-44800.rs
+++ b/src/test/run-pass-valgrind/issue-44800.rs
@@ -8,11 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(global_allocator, alloc_system, allocator_api)]
-extern crate alloc_system;
-
+use std::alloc::System;
 use std::collections::VecDeque;
-use alloc_system::System;
 
 #[global_allocator]
 static ALLOCATOR: System = System;
diff --git a/src/test/run-pass/allocator/auxiliary/custom-as-global.rs b/src/test/run-pass/allocator/auxiliary/custom-as-global.rs
index 538f36faadf..a3f05a01c5a 100644
--- a/src/test/run-pass/allocator/auxiliary/custom-as-global.rs
+++ b/src/test/run-pass/allocator/auxiliary/custom-as-global.rs
@@ -10,7 +10,6 @@
 
 // no-prefer-dynamic
 
-#![feature(global_allocator)]
 #![crate_type = "rlib"]
 
 extern crate custom;
diff --git a/src/test/run-pass/allocator/auxiliary/custom.rs b/src/test/run-pass/allocator/auxiliary/custom.rs
index 91f70aa83e8..02e86fa19f8 100644
--- a/src/test/run-pass/allocator/auxiliary/custom.rs
+++ b/src/test/run-pass/allocator/auxiliary/custom.rs
@@ -13,18 +13,18 @@
 #![feature(heap_api, allocator_api)]
 #![crate_type = "rlib"]
 
-use std::alloc::{GlobalAlloc, System, Layout, Opaque};
+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 Opaque {
+    unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
         self.0.fetch_add(1, Ordering::SeqCst);
         System.alloc(layout)
     }
 
-    unsafe fn dealloc(&self, ptr: *mut Opaque, layout: 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/run-pass/allocator/custom.rs b/src/test/run-pass/allocator/custom.rs
index 415d39a593e..3a7f8fa8620 100644
--- a/src/test/run-pass/allocator/custom.rs
+++ b/src/test/run-pass/allocator/custom.rs
@@ -11,11 +11,11 @@
 // aux-build:helper.rs
 // no-prefer-dynamic
 
-#![feature(global_allocator, heap_api, allocator_api)]
+#![feature(allocator_api)]
 
 extern crate helper;
 
-use std::alloc::{self, Global, Alloc, System, Layout, Opaque};
+use std::alloc::{self, Global, Alloc, System, Layout};
 use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
 
 static HITS: AtomicUsize = ATOMIC_USIZE_INIT;
@@ -23,12 +23,12 @@ static HITS: AtomicUsize = ATOMIC_USIZE_INIT;
 struct A;
 
 unsafe impl alloc::GlobalAlloc for A {
-    unsafe fn alloc(&self, layout: Layout) -> *mut Opaque {
+    unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
         HITS.fetch_add(1, Ordering::SeqCst);
         System.alloc(layout)
     }
 
-    unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout) {
+    unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
         HITS.fetch_add(1, Ordering::SeqCst);
         System.dealloc(ptr, layout)
     }
diff --git a/src/test/run-pass/allocator/xcrate-use.rs b/src/test/run-pass/allocator/xcrate-use.rs
index 78d604a7108..482e3b04aae 100644
--- a/src/test/run-pass/allocator/xcrate-use.rs
+++ b/src/test/run-pass/allocator/xcrate-use.rs
@@ -12,7 +12,7 @@
 // aux-build:helper.rs
 // no-prefer-dynamic
 
-#![feature(global_allocator, heap_api, allocator_api)]
+#![feature(allocator_api)]
 
 extern crate custom;
 extern crate helper;
diff --git a/src/test/run-pass/allocator/xcrate-use2.rs b/src/test/run-pass/allocator/xcrate-use2.rs
index b8e844522dc..fbde7e855c2 100644
--- a/src/test/run-pass/allocator/xcrate-use2.rs
+++ b/src/test/run-pass/allocator/xcrate-use2.rs
@@ -19,7 +19,7 @@ extern crate custom;
 extern crate custom_as_global;
 extern crate helper;
 
-use std::alloc::{Global, Alloc, GlobalAlloc, System, Layout};
+use std::alloc::{alloc, dealloc, GlobalAlloc, System, Layout};
 use std::sync::atomic::{Ordering, ATOMIC_USIZE_INIT};
 
 static GLOBAL: custom::A = custom::A(ATOMIC_USIZE_INIT);
@@ -30,10 +30,10 @@ fn main() {
         let layout = Layout::from_size_align(4, 2).unwrap();
 
         // Global allocator routes to the `custom_as_global` global
-        let ptr = Global.alloc(layout.clone());
+        let ptr = alloc(layout.clone());
         helper::work_with(&ptr);
         assert_eq!(custom_as_global::get(), n + 1);
-        Global.dealloc(ptr, layout.clone());
+        dealloc(ptr, layout.clone());
         assert_eq!(custom_as_global::get(), n + 2);
 
         // Usage of the system allocator avoids all globals
diff --git a/src/test/run-pass/realloc-16687.rs b/src/test/run-pass/realloc-16687.rs
index febd249d776..7152e721eac 100644
--- a/src/test/run-pass/realloc-16687.rs
+++ b/src/test/run-pass/realloc-16687.rs
@@ -64,7 +64,7 @@ unsafe fn test_triangle() -> bool {
             println!("deallocate({:?}, {:?}", ptr, layout);
         }
 
-        Global.dealloc(NonNull::new_unchecked(ptr).as_opaque(), layout);
+        Global.dealloc(NonNull::new_unchecked(ptr), layout);
     }
 
     unsafe fn reallocate(ptr: *mut u8, old: Layout, new: Layout) -> *mut u8 {
@@ -72,7 +72,7 @@ unsafe fn test_triangle() -> bool {
             println!("reallocate({:?}, old={:?}, new={:?})", ptr, old, new);
         }
 
-        let ret = Global.realloc(NonNull::new_unchecked(ptr).as_opaque(), old, new.size())
+        let ret = Global.realloc(NonNull::new_unchecked(ptr), old, new.size())
             .unwrap_or_else(|_| oom(Layout::from_size_align_unchecked(new.size(), old.align())));
 
         if PRINT {
diff --git a/src/test/run-pass/thin-lto-global-allocator.rs b/src/test/run-pass/thin-lto-global-allocator.rs
index a0534ff6735..3a0e2fe01db 100644
--- a/src/test/run-pass/thin-lto-global-allocator.rs
+++ b/src/test/run-pass/thin-lto-global-allocator.rs
@@ -11,8 +11,6 @@
 // compile-flags: -Z thinlto -C codegen-units=2
 // min-llvm-version 4.0
 
-#![feature(allocator_api, global_allocator)]
-
 #[global_allocator]
 static A: std::alloc::System = std::alloc::System;
 
diff --git a/src/test/ui/feature-gate-global_allocator.rs b/src/test/ui/feature-gate-global_allocator.rs
deleted file mode 100644
index ff3c342f9e0..00000000000
--- a/src/test/ui/feature-gate-global_allocator.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[global_allocator] //~ ERROR: attribute is an experimental feature
-static A: usize = 0;
-
-fn main() {}
diff --git a/src/test/ui/feature-gate-global_allocator.stderr b/src/test/ui/feature-gate-global_allocator.stderr
deleted file mode 100644
index 9f8b98ede09..00000000000
--- a/src/test/ui/feature-gate-global_allocator.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0658]: the `#[global_allocator]` attribute is an experimental feature (see issue #27389)
-  --> $DIR/feature-gate-global_allocator.rs:11:1
-   |
-LL | #[global_allocator] //~ ERROR: attribute is an experimental feature
-   | ^^^^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(global_allocator)] to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.