about summary refs log tree commit diff
path: root/src/test/ui/allocator
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2018-08-19 18:34:46 +0200
committerGitHub <noreply@github.com>2018-08-19 18:34:46 +0200
commit08b1d83a46848dd7bd778aeae67a1e529e95d8cd (patch)
tree9153a34f91860b175afb24f904fd50ac09e77c4e /src/test/ui/allocator
parentac64ef33756d05557153e00211cdf8fcf65d4be3 (diff)
parentb355906919927ab3c879becd14392f023af883a1 (diff)
downloadrust-08b1d83a46848dd7bd778aeae67a1e529e95d8cd.tar.gz
rust-08b1d83a46848dd7bd778aeae67a1e529e95d8cd.zip
Merge branch 'master' into feature/core_convert_id
Diffstat (limited to 'src/test/ui/allocator')
-rw-r--r--src/test/ui/allocator/auxiliary/system-allocator.rs18
-rw-r--r--src/test/ui/allocator/auxiliary/system-allocator2.rs18
-rw-r--r--src/test/ui/allocator/function-allocator.rs15
-rw-r--r--src/test/ui/allocator/function-allocator.stderr8
-rw-r--r--src/test/ui/allocator/not-an-allocator.rs18
-rw-r--r--src/test/ui/allocator/not-an-allocator.stderr35
-rw-r--r--src/test/ui/allocator/two-allocators.rs20
-rw-r--r--src/test/ui/allocator/two-allocators.stderr8
-rw-r--r--src/test/ui/allocator/two-allocators2.rs23
-rw-r--r--src/test/ui/allocator/two-allocators2.stderr4
-rw-r--r--src/test/ui/allocator/two-allocators3.rs20
-rw-r--r--src/test/ui/allocator/two-allocators3.stderr4
12 files changed, 191 insertions, 0 deletions
diff --git a/src/test/ui/allocator/auxiliary/system-allocator.rs b/src/test/ui/allocator/auxiliary/system-allocator.rs
new file mode 100644
index 00000000000..e5650d5b7b0
--- /dev/null
+++ b/src/test/ui/allocator/auxiliary/system-allocator.rs
@@ -0,0 +1,18 @@
+// 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.
+
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+
+use std::alloc::System;
+
+#[global_allocator]
+static A: System = System;
diff --git a/src/test/ui/allocator/auxiliary/system-allocator2.rs b/src/test/ui/allocator/auxiliary/system-allocator2.rs
new file mode 100644
index 00000000000..e5650d5b7b0
--- /dev/null
+++ b/src/test/ui/allocator/auxiliary/system-allocator2.rs
@@ -0,0 +1,18 @@
+// 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.
+
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+
+use std::alloc::System;
+
+#[global_allocator]
+static A: System = System;
diff --git a/src/test/ui/allocator/function-allocator.rs b/src/test/ui/allocator/function-allocator.rs
new file mode 100644
index 00000000000..989c102b86e
--- /dev/null
+++ b/src/test/ui/allocator/function-allocator.rs
@@ -0,0 +1,15 @@
+// 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]
+fn foo() {} //~ ERROR: allocators must be statics
+
+fn main() {}
diff --git a/src/test/ui/allocator/function-allocator.stderr b/src/test/ui/allocator/function-allocator.stderr
new file mode 100644
index 00000000000..8649b6b1244
--- /dev/null
+++ b/src/test/ui/allocator/function-allocator.stderr
@@ -0,0 +1,8 @@
+error: allocators must be statics
+  --> $DIR/function-allocator.rs:13:1
+   |
+LL | fn foo() {} //~ ERROR: allocators must be statics
+   | ^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/allocator/not-an-allocator.rs b/src/test/ui/allocator/not-an-allocator.rs
new file mode 100644
index 00000000000..6559335960a
--- /dev/null
+++ b/src/test/ui/allocator/not-an-allocator.rs
@@ -0,0 +1,18 @@
+// 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]
+static A: usize = 0;
+//~^ the trait bound `usize:
+//~| the trait bound `usize:
+//~| the trait bound `usize:
+//~| the trait bound `usize:
+
+fn main() {}
diff --git a/src/test/ui/allocator/not-an-allocator.stderr b/src/test/ui/allocator/not-an-allocator.stderr
new file mode 100644
index 00000000000..757c5066a66
--- /dev/null
+++ b/src/test/ui/allocator/not-an-allocator.stderr
@@ -0,0 +1,35 @@
+error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied
+  --> $DIR/not-an-allocator.rs:12:1
+   |
+LL | static A: usize = 0;
+   | ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize`
+   |
+   = note: required by `std::alloc::GlobalAlloc::alloc`
+
+error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied
+  --> $DIR/not-an-allocator.rs:12:1
+   |
+LL | static A: usize = 0;
+   | ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize`
+   |
+   = note: required by `std::alloc::GlobalAlloc::dealloc`
+
+error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied
+  --> $DIR/not-an-allocator.rs:12:1
+   |
+LL | static A: usize = 0;
+   | ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize`
+   |
+   = note: required by `std::alloc::GlobalAlloc::realloc`
+
+error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied
+  --> $DIR/not-an-allocator.rs:12:1
+   |
+LL | static A: usize = 0;
+   | ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize`
+   |
+   = note: required by `std::alloc::GlobalAlloc::alloc_zeroed`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/allocator/two-allocators.rs b/src/test/ui/allocator/two-allocators.rs
new file mode 100644
index 00000000000..7a97a11df20
--- /dev/null
+++ b/src/test/ui/allocator/two-allocators.rs
@@ -0,0 +1,20 @@
+// 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.
+
+use std::alloc::System;
+
+#[global_allocator]
+static A: System = System;
+#[global_allocator]
+static B: System = System;
+//~^ ERROR: cannot define more than one #[global_allocator]
+
+fn main() {}
+
diff --git a/src/test/ui/allocator/two-allocators.stderr b/src/test/ui/allocator/two-allocators.stderr
new file mode 100644
index 00000000000..5285ee93f2d
--- /dev/null
+++ b/src/test/ui/allocator/two-allocators.stderr
@@ -0,0 +1,8 @@
+error: cannot define more than one #[global_allocator]
+  --> $DIR/two-allocators.rs:16:1
+   |
+LL | static B: System = System;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/allocator/two-allocators2.rs b/src/test/ui/allocator/two-allocators2.rs
new file mode 100644
index 00000000000..e747140dfe5
--- /dev/null
+++ b/src/test/ui/allocator/two-allocators2.rs
@@ -0,0 +1,23 @@
+// 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.
+
+// aux-build:system-allocator.rs
+// no-prefer-dynamic
+// error-pattern: the #[global_allocator] in
+
+extern crate system_allocator;
+
+use std::alloc::System;
+
+#[global_allocator]
+static A: System = System;
+
+fn main() {}
+
diff --git a/src/test/ui/allocator/two-allocators2.stderr b/src/test/ui/allocator/two-allocators2.stderr
new file mode 100644
index 00000000000..2b23ce38ede
--- /dev/null
+++ b/src/test/ui/allocator/two-allocators2.stderr
@@ -0,0 +1,4 @@
+error: the #[global_allocator] in this crate conflicts with global allocator in: system_allocator
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/allocator/two-allocators3.rs b/src/test/ui/allocator/two-allocators3.rs
new file mode 100644
index 00000000000..dd86b02bd20
--- /dev/null
+++ b/src/test/ui/allocator/two-allocators3.rs
@@ -0,0 +1,20 @@
+// 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.
+
+// aux-build:system-allocator.rs
+// aux-build:system-allocator2.rs
+// no-prefer-dynamic
+// error-pattern: the #[global_allocator] in
+
+
+extern crate system_allocator;
+extern crate system_allocator2;
+
+fn main() {}
diff --git a/src/test/ui/allocator/two-allocators3.stderr b/src/test/ui/allocator/two-allocators3.stderr
new file mode 100644
index 00000000000..86e385a96a1
--- /dev/null
+++ b/src/test/ui/allocator/two-allocators3.stderr
@@ -0,0 +1,4 @@
+error: the #[global_allocator] in system_allocator conflicts with this global allocator in: system_allocator2
+
+error: aborting due to previous error
+