about summary refs log tree commit diff
path: root/src/test/ui/box
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /src/test/ui/box
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'src/test/ui/box')
-rw-r--r--src/test/ui/box/alloc-unstable-fail.rs6
-rw-r--r--src/test/ui/box/alloc-unstable-fail.stderr12
-rw-r--r--src/test/ui/box/alloc-unstable.rs8
-rw-r--r--src/test/ui/box/into-boxed-slice-fail.rs14
-rw-r--r--src/test/ui/box/into-boxed-slice-fail.stderr45
-rw-r--r--src/test/ui/box/into-boxed-slice.rs11
-rw-r--r--src/test/ui/box/issue-82446.rs15
-rw-r--r--src/test/ui/box/issue-82446.stderr12
-rw-r--r--src/test/ui/box/issue-95036.rs22
-rw-r--r--src/test/ui/box/large-allocator-ice.rs29
-rw-r--r--src/test/ui/box/leak-alloc.rs29
-rw-r--r--src/test/ui/box/leak-alloc.stderr15
-rw-r--r--src/test/ui/box/new-box-syntax.rs27
-rw-r--r--src/test/ui/box/new-box.rs30
-rw-r--r--src/test/ui/box/new.rs6
-rw-r--r--src/test/ui/box/thin_align.rs26
-rw-r--r--src/test/ui/box/thin_drop.rs37
-rw-r--r--src/test/ui/box/thin_new.rs30
-rw-r--r--src/test/ui/box/thin_zst.rs34
19 files changed, 0 insertions, 408 deletions
diff --git a/src/test/ui/box/alloc-unstable-fail.rs b/src/test/ui/box/alloc-unstable-fail.rs
deleted file mode 100644
index 9427571648c..00000000000
--- a/src/test/ui/box/alloc-unstable-fail.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-use std::boxed::Box;
-
-fn main() {
-    let _boxed: Box<u32, _> = Box::new(10);
-    //~^ ERROR use of unstable library feature 'allocator_api'
-}
diff --git a/src/test/ui/box/alloc-unstable-fail.stderr b/src/test/ui/box/alloc-unstable-fail.stderr
deleted file mode 100644
index 03ae36e8890..00000000000
--- a/src/test/ui/box/alloc-unstable-fail.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0658]: use of unstable library feature 'allocator_api'
-  --> $DIR/alloc-unstable-fail.rs:4:26
-   |
-LL |     let _boxed: Box<u32, _> = Box::new(10);
-   |                          ^
-   |
-   = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
-   = help: add `#![feature(allocator_api)]` to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/box/alloc-unstable.rs b/src/test/ui/box/alloc-unstable.rs
deleted file mode 100644
index 66388d0d512..00000000000
--- a/src/test/ui/box/alloc-unstable.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-// run-pass
-#![feature(allocator_api)]
-
-use std::boxed::Box;
-
-fn main() {
-    let _boxed: Box<u32, _> = Box::new(10);
-}
diff --git a/src/test/ui/box/into-boxed-slice-fail.rs b/src/test/ui/box/into-boxed-slice-fail.rs
deleted file mode 100644
index 49dbb170f8e..00000000000
--- a/src/test/ui/box/into-boxed-slice-fail.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-#![feature(box_into_boxed_slice)]
-
-use std::boxed::Box;
-use std::fmt::Debug;
-fn main() {
-    let boxed_slice = Box::new([1,2,3]) as Box<[u8]>;
-    let _ = Box::into_boxed_slice(boxed_slice);
-    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
-    //~^^ ERROR the size for values of type `[u8]` cannot be known at compilation time
-    let boxed_trait: Box<dyn Debug> = Box::new(5u8);
-    let _ = Box::into_boxed_slice(boxed_trait);
-    //~^ ERROR the size for values of type `dyn Debug` cannot be known at compilation time
-    //~^^ ERROR the size for values of type `dyn Debug` cannot be known at compilation time
-}
diff --git a/src/test/ui/box/into-boxed-slice-fail.stderr b/src/test/ui/box/into-boxed-slice-fail.stderr
deleted file mode 100644
index f102f666dc2..00000000000
--- a/src/test/ui/box/into-boxed-slice-fail.stderr
+++ /dev/null
@@ -1,45 +0,0 @@
-error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
-  --> $DIR/into-boxed-slice-fail.rs:7:35
-   |
-LL |     let _ = Box::into_boxed_slice(boxed_slice);
-   |             --------------------- ^^^^^^^^^^^ doesn't have a size known at compile-time
-   |             |
-   |             required by a bound introduced by this call
-   |
-   = help: the trait `Sized` is not implemented for `[u8]`
-note: required by a bound in `Box::<T, A>::into_boxed_slice`
-  --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
-
-error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
-  --> $DIR/into-boxed-slice-fail.rs:7:13
-   |
-LL |     let _ = Box::into_boxed_slice(boxed_slice);
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
-   |
-   = help: the trait `Sized` is not implemented for `[u8]`
-   = note: slice and array elements must have `Sized` type
-
-error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
-  --> $DIR/into-boxed-slice-fail.rs:11:35
-   |
-LL |     let _ = Box::into_boxed_slice(boxed_trait);
-   |             --------------------- ^^^^^^^^^^^ doesn't have a size known at compile-time
-   |             |
-   |             required by a bound introduced by this call
-   |
-   = help: the trait `Sized` is not implemented for `dyn Debug`
-note: required by a bound in `Box::<T, A>::into_boxed_slice`
-  --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
-
-error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
-  --> $DIR/into-boxed-slice-fail.rs:11:13
-   |
-LL |     let _ = Box::into_boxed_slice(boxed_trait);
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
-   |
-   = help: the trait `Sized` is not implemented for `dyn Debug`
-   = note: slice and array elements must have `Sized` type
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/box/into-boxed-slice.rs b/src/test/ui/box/into-boxed-slice.rs
deleted file mode 100644
index 61b3d915253..00000000000
--- a/src/test/ui/box/into-boxed-slice.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// run-pass
-#![feature(box_into_boxed_slice)]
-
-use std::boxed::Box;
-fn main() {
-    assert_eq!(Box::into_boxed_slice(Box::new(5u8)), Box::new([5u8]) as Box<[u8]>);
-    assert_eq!(Box::into_boxed_slice(Box::new([25u8])), Box::new([[25u8]]) as Box<[[u8; 1]]>);
-    let a: Box<[Box<[u8; 1]>]> = Box::into_boxed_slice(Box::new(Box::new([5u8])));
-    let b: Box<[Box<[u8; 1]>]> = Box::new([Box::new([5u8])]);
-    assert_eq!(a, b);
-}
diff --git a/src/test/ui/box/issue-82446.rs b/src/test/ui/box/issue-82446.rs
deleted file mode 100644
index 2960f7fbc21..00000000000
--- a/src/test/ui/box/issue-82446.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// https://github.com/rust-lang/rust/issues/82446
-// Spurious 'help: store this in the heap' regression test
-trait MyTrait {}
-
-struct Foo {
-    val: Box<dyn MyTrait>
-}
-
-fn make_it(val: &Box<dyn MyTrait>) {
-    Foo {
-        val //~ ERROR [E0308]
-    };
-}
-
-fn main() {}
diff --git a/src/test/ui/box/issue-82446.stderr b/src/test/ui/box/issue-82446.stderr
deleted file mode 100644
index 0374737957e..00000000000
--- a/src/test/ui/box/issue-82446.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/issue-82446.rs:11:9
-   |
-LL |         val
-   |         ^^^ expected struct `Box`, found reference
-   |
-   = note: expected struct `Box<(dyn MyTrait + 'static)>`
-           found reference `&Box<(dyn MyTrait + 'static)>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/box/issue-95036.rs b/src/test/ui/box/issue-95036.rs
deleted file mode 100644
index 0611fabc15c..00000000000
--- a/src/test/ui/box/issue-95036.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-// compile-flags: -O
-// build-pass
-
-#![feature(allocator_api)]
-
-#[inline(never)]
-pub fn by_ref(node: &mut Box<[u8; 1], &std::alloc::Global>) {
-    node[0] = 9u8;
-}
-
-pub fn main() {
-    let mut node = Box::new_in([5u8], &std::alloc::Global);
-    node[0] = 7u8;
-
-    std::hint::black_box(node);
-
-    let mut node = Box::new_in([5u8], &std::alloc::Global);
-
-    by_ref(&mut node);
-
-    std::hint::black_box(node);
-}
diff --git a/src/test/ui/box/large-allocator-ice.rs b/src/test/ui/box/large-allocator-ice.rs
deleted file mode 100644
index b3a882ff089..00000000000
--- a/src/test/ui/box/large-allocator-ice.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// build-pass
-#![feature(allocator_api)]
-#![allow(unused_must_use)]
-
-use std::alloc::Allocator;
-
-struct BigAllocator([usize; 2]);
-
-unsafe impl Allocator for BigAllocator {
-    fn allocate(
-        &self,
-        _: std::alloc::Layout,
-    ) -> Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError> {
-        todo!()
-    }
-    unsafe fn deallocate(&self, _: std::ptr::NonNull<u8>, _: std::alloc::Layout) {
-        todo!()
-    }
-}
-
-fn main() {
-    Box::new_in((), &std::alloc::Global);
-    Box::new_in((), BigAllocator([0; 2]));
-    generic_function(0);
-}
-
-fn generic_function<T>(val: T) {
-    *Box::new_in(val, &std::alloc::Global);
-}
diff --git a/src/test/ui/box/leak-alloc.rs b/src/test/ui/box/leak-alloc.rs
deleted file mode 100644
index 3f0f39f448b..00000000000
--- a/src/test/ui/box/leak-alloc.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-#![feature(allocator_api)]
-
-use std::alloc::{AllocError, Allocator, Layout, System};
-use std::ptr::NonNull;
-
-use std::boxed::Box;
-
-struct Alloc {}
-
-unsafe impl Allocator for Alloc {
-    fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
-        System.allocate(layout)
-    }
-
-    unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
-        System.deallocate(ptr, layout)
-    }
-}
-
-fn use_value(_: u32) {}
-
-fn main() {
-    let alloc = Alloc {};
-    let boxed = Box::new_in(10, alloc.by_ref());
-    let theref = Box::leak(boxed);
-    drop(alloc);
-    //~^ ERROR cannot move out of `alloc` because it is borrowed
-    use_value(*theref)
-}
diff --git a/src/test/ui/box/leak-alloc.stderr b/src/test/ui/box/leak-alloc.stderr
deleted file mode 100644
index e8a6ad0995a..00000000000
--- a/src/test/ui/box/leak-alloc.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0505]: cannot move out of `alloc` because it is borrowed
-  --> $DIR/leak-alloc.rs:26:10
-   |
-LL |     let boxed = Box::new_in(10, alloc.by_ref());
-   |                                 -------------- borrow of `alloc` occurs here
-LL |     let theref = Box::leak(boxed);
-LL |     drop(alloc);
-   |          ^^^^^ move out of `alloc` occurs here
-LL |
-LL |     use_value(*theref)
-   |               ------- borrow later used here
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0505`.
diff --git a/src/test/ui/box/new-box-syntax.rs b/src/test/ui/box/new-box-syntax.rs
deleted file mode 100644
index c56e1dd4625..00000000000
--- a/src/test/ui/box/new-box-syntax.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-// run-pass
-// pretty-expanded FIXME #23616
-
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-#![allow(dead_code, unused_variables)]
-
-// Tests that the new `box` syntax works with unique pointers.
-
-use std::boxed::Box;
-
-struct Structure {
-    x: isize,
-    y: isize,
-}
-
-pub fn main() {
-    let y: Box<isize> = Box::new(2);
-    let b: Box<isize> = Box::new(1 + 2);
-    let c = Box::new(3 + 4);
-
-    let s: Box<Structure> = Box::new(Structure {
-        x: 3,
-        y: 4,
-    });
-}
diff --git a/src/test/ui/box/new-box.rs b/src/test/ui/box/new-box.rs
deleted file mode 100644
index 96a3b197f46..00000000000
--- a/src/test/ui/box/new-box.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// run-pass
-
-fn f(x: Box<isize>) {
-    let y: &isize = &*x;
-    println!("{}", *x);
-    println!("{}", *y);
-}
-
-trait Trait {
-    fn printme(&self);
-}
-
-struct Struct;
-
-impl Trait for Struct {
-    fn printme(&self) {
-        println!("hello world!");
-    }
-}
-
-fn g(x: Box<dyn Trait>) {
-    x.printme();
-    let y: &dyn Trait = &*x;
-    y.printme();
-}
-
-fn main() {
-    f(Box::new(1234));
-    g(Box::new(Struct) as Box<dyn Trait>);
-}
diff --git a/src/test/ui/box/new.rs b/src/test/ui/box/new.rs
deleted file mode 100644
index be1a40cf779..00000000000
--- a/src/test/ui/box/new.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-// run-pass
-// pretty-expanded FIXME #23616
-
-fn main() {
-    let _a = Box::new(1);
-}
diff --git a/src/test/ui/box/thin_align.rs b/src/test/ui/box/thin_align.rs
deleted file mode 100644
index 3c61d0090e4..00000000000
--- a/src/test/ui/box/thin_align.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-#![feature(thin_box)]
-// run-pass
-use std::boxed::ThinBox;
-use std::error::Error;
-use std::ops::Deref;
-use std::fmt;
-
-fn main() {
-    let expected = "Foo error!";
-    let a: ThinBox<dyn Error> = ThinBox::new_unsize(Foo(expected));
-    let a = a.deref();
-    let msg = a.to_string();
-    assert_eq!(expected, msg);
-}
-
-#[derive(Debug)]
-#[repr(align(1024))]
-struct Foo(&'static str);
-
-impl fmt::Display for Foo {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "{}", self.0)
-    }
-}
-
-impl Error for Foo {}
diff --git a/src/test/ui/box/thin_drop.rs b/src/test/ui/box/thin_drop.rs
deleted file mode 100644
index 965613c114e..00000000000
--- a/src/test/ui/box/thin_drop.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#![feature(thin_box)]
-// run-pass
-use std::boxed::ThinBox;
-use std::error::Error;
-use std::ops::Deref;
-use std::fmt;
-
-fn main() {
-    let expected = "Foo error!";
-    let mut dropped = false;
-    {
-        let foo = Foo(expected, &mut dropped);
-        let a: ThinBox<dyn Error> = ThinBox::new_unsize(foo);
-        let a = a.deref();
-        let msg = a.to_string();
-        assert_eq!(expected, msg);
-    }
-    assert!(dropped);
-}
-
-#[derive(Debug)]
-#[repr(align(1024))]
-struct Foo<'a>(&'static str, &'a mut bool);
-
-impl Drop for Foo<'_> {
-    fn drop(&mut self) {
-        *self.1 = true;
-    }
-}
-
-impl fmt::Display for Foo<'_> {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "{}", self.0)
-    }
-}
-
-impl Error for Foo<'_> {}
diff --git a/src/test/ui/box/thin_new.rs b/src/test/ui/box/thin_new.rs
deleted file mode 100644
index 53f46478be4..00000000000
--- a/src/test/ui/box/thin_new.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-#![feature(thin_box)]
-// run-pass
-use std::boxed::ThinBox;
-use std::error::Error;
-use std::{fmt, mem};
-
-fn main() {
-    let thin_error: ThinBox<dyn Error> = ThinBox::new_unsize(Foo);
-    assert_eq!(mem::size_of::<*const i32>(), mem::size_of_val(&thin_error));
-    println!("{:?}", thin_error);
-
-    let thin = ThinBox::new(42i32);
-    assert_eq!(mem::size_of::<*const i32>(), mem::size_of_val(&thin));
-    println!("{:?}", thin);
-
-    let thin_slice = ThinBox::<[i32]>::new_unsize([1, 2, 3, 4]);
-    assert_eq!(mem::size_of::<*const i32>(), mem::size_of_val(&thin_slice));
-    println!("{:?}", thin_slice);
-}
-
-#[derive(Debug)]
-struct Foo;
-
-impl fmt::Display for Foo {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "boooo!")
-    }
-}
-
-impl Error for Foo {}
diff --git a/src/test/ui/box/thin_zst.rs b/src/test/ui/box/thin_zst.rs
deleted file mode 100644
index 77c400d17bb..00000000000
--- a/src/test/ui/box/thin_zst.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-#![feature(thin_box)]
-// run-pass
-use std::boxed::ThinBox;
-use std::error::Error;
-use std::{fmt, mem};
-use std::ops::DerefMut;
-
-const EXPECTED: &str = "boooo!";
-
-fn main() {
-    let thin_error: ThinBox<dyn Error> = ThinBox::new_unsize(Foo);
-    assert_eq!(mem::size_of::<*const i32>(), mem::size_of_val(&thin_error));
-    let msg = thin_error.to_string();
-    assert_eq!(EXPECTED, msg);
-
-    let mut thin_concrete_error: ThinBox<Foo> = ThinBox::new(Foo);
-    assert_eq!(mem::size_of::<*const i32>(), mem::size_of_val(&thin_concrete_error));
-    let msg = thin_concrete_error.to_string();
-    assert_eq!(EXPECTED, msg);
-    let inner = thin_concrete_error.deref_mut();
-    let msg = inner.to_string();
-    assert_eq!(EXPECTED, msg);
-}
-
-#[derive(Debug)]
-struct Foo;
-
-impl fmt::Display for Foo {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "{}", EXPECTED)
-    }
-}
-
-impl Error for Foo {}