diff options
| author | David Wood <david@davidtw.co> | 2018-08-08 14:50:16 +0200 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2018-08-14 11:12:09 +0200 |
| commit | 3fc7ab237314a4ce85e612b4ce590c27f1425291 (patch) | |
| tree | c775f852e05e1272032cb053ee347315c973c7b5 /src/test/ui/allocator | |
| parent | 3e0a4079884eab5b54489c92f7428cda2797ea5c (diff) | |
| download | rust-3fc7ab237314a4ce85e612b4ce590c27f1425291.tar.gz rust-3fc7ab237314a4ce85e612b4ce590c27f1425291.zip | |
Merged migrated compile-fail tests and ui tests. Fixes #46841.
Diffstat (limited to 'src/test/ui/allocator')
| -rw-r--r-- | src/test/ui/allocator/auxiliary/system-allocator.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/allocator/auxiliary/system-allocator2.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/allocator/function-allocator.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/allocator/function-allocator.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/allocator/not-an-allocator.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/allocator/not-an-allocator.stderr | 35 | ||||
| -rw-r--r-- | src/test/ui/allocator/two-allocators.rs | 20 | ||||
| -rw-r--r-- | src/test/ui/allocator/two-allocators.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/allocator/two-allocators2.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/allocator/two-allocators2.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/allocator/two-allocators3.rs | 20 | ||||
| -rw-r--r-- | src/test/ui/allocator/two-allocators3.stderr | 4 |
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 + |
