diff options
| author | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-05 09:13:28 +0100 |
|---|---|---|
| committer | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-11 09:32:08 +0000 |
| commit | cf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch) | |
| tree | 40a88d9a46aaf3e8870676eb2538378b75a263eb /src/test/ui/consts/std | |
| parent | ca855e6e42787ecd062d81d53336fe6788ef51a9 (diff) | |
| download | rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip | |
Move /src/test to /tests
Diffstat (limited to 'src/test/ui/consts/std')
| -rw-r--r-- | src/test/ui/consts/std/alloc.32bit.stderr | 25 | ||||
| -rw-r--r-- | src/test/ui/consts/std/alloc.64bit.stderr | 25 | ||||
| -rw-r--r-- | src/test/ui/consts/std/alloc.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/consts/std/cell.rs | 46 | ||||
| -rw-r--r-- | src/test/ui/consts/std/cell.stderr | 26 | ||||
| -rw-r--r-- | src/test/ui/consts/std/iter.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/consts/std/slice.rs | 10 |
7 files changed, 0 insertions, 160 deletions
diff --git a/src/test/ui/consts/std/alloc.32bit.stderr b/src/test/ui/consts/std/alloc.32bit.stderr deleted file mode 100644 index 8c83df53dad..00000000000 --- a/src/test/ui/consts/std/alloc.32bit.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:12:1 - | -LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000000, but expected a valid enum tag - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:16:1 - | -LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000003, but expected a valid enum tag - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/std/alloc.64bit.stderr b/src/test/ui/consts/std/alloc.64bit.stderr deleted file mode 100644 index addedad1704..00000000000 --- a/src/test/ui/consts/std/alloc.64bit.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:12:1 - | -LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:16:1 - | -LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000003, but expected a valid enum tag - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/std/alloc.rs b/src/test/ui/consts/std/alloc.rs deleted file mode 100644 index 9abf35d63d3..00000000000 --- a/src/test/ui/consts/std/alloc.rs +++ /dev/null @@ -1,19 +0,0 @@ -// stderr-per-bitwidth -// ignore-debug (the debug assertions change the error) -// Strip out raw byte dumps to make comparison platform-independent: -// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" -// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" -use std::alloc::Layout; - -// ok -const LAYOUT_VALID: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x08) }; - -// not ok, since alignment needs to be non-zero. -const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) }; -//~^ ERROR it is undefined behavior to use this value - -// not ok, since alignment needs to be a power of two. -const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) }; -//~^ ERROR it is undefined behavior to use this value - -fn main() {} diff --git a/src/test/ui/consts/std/cell.rs b/src/test/ui/consts/std/cell.rs deleted file mode 100644 index f1ef541319a..00000000000 --- a/src/test/ui/consts/std/cell.rs +++ /dev/null @@ -1,46 +0,0 @@ -#![feature(const_refs_to_cell)] - -use std::cell::*; - -// not ok, because this creates a dangling pointer, just like `let x = Cell::new(42).as_ptr()` would -static FOO: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr()); -//~^ ERROR encountered dangling pointer -const FOO_CONST: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr()); -//~^ ERROR encountered dangling pointer - -// Ok, these are just base values and it is the `Wrap` author's job to uphold `Send` and `Sync` -// invariants, since they used `unsafe impl`. -static FOO3: Wrap<Cell<u32>> = Wrap(Cell::new(42)); -const FOO3_CONST: Wrap<Cell<u32>> = Wrap(Cell::new(42)); - -// ok, we are referring to the memory of another static item. -static FOO4: Wrap<*mut u32> = Wrap(FOO3.0.as_ptr()); - -// not ok, the use of a constant here is equivalent to an inline declaration of the value, so -// its memory will get freed before the constant is finished evaluating, thus creating a dangling -// pointer. This would happen exactly the same at runtime. -const FOO4_CONST: Wrap<*mut u32> = Wrap(FOO3_CONST.0.as_ptr()); -//~^ ERROR encountered dangling pointer - -// not ok, because the `as_ptr` call takes a reference to a temporary that will get freed -// before the constant is finished evaluating. -const FOO2: *mut u32 = Cell::new(42).as_ptr(); -//~^ ERROR encountered dangling pointer - -struct IMSafeTrustMe(UnsafeCell<u32>); -unsafe impl Send for IMSafeTrustMe {} -unsafe impl Sync for IMSafeTrustMe {} - -static BAR: IMSafeTrustMe = IMSafeTrustMe(UnsafeCell::new(5)); - - - -struct Wrap<T>(T); -unsafe impl<T> Send for Wrap<T> {} -unsafe impl<T> Sync for Wrap<T> {} - -static BAR_PTR: Wrap<*mut u32> = Wrap(BAR.0.get()); - -const fn fst_ref<T, U>(x: &(T, U)) -> &T { &x.0 } - -fn main() {} diff --git a/src/test/ui/consts/std/cell.stderr b/src/test/ui/consts/std/cell.stderr deleted file mode 100644 index 937fa7db0c8..00000000000 --- a/src/test/ui/consts/std/cell.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: encountered dangling pointer in final constant - --> $DIR/cell.rs:6:1 - | -LL | static FOO: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: encountered dangling pointer in final constant - --> $DIR/cell.rs:8:1 - | -LL | const FOO_CONST: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: encountered dangling pointer in final constant - --> $DIR/cell.rs:22:1 - | -LL | const FOO4_CONST: Wrap<*mut u32> = Wrap(FOO3_CONST.0.as_ptr()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: encountered dangling pointer in final constant - --> $DIR/cell.rs:27:1 - | -LL | const FOO2: *mut u32 = Cell::new(42).as_ptr(); - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/consts/std/iter.rs b/src/test/ui/consts/std/iter.rs deleted file mode 100644 index e9af781eb2b..00000000000 --- a/src/test/ui/consts/std/iter.rs +++ /dev/null @@ -1,9 +0,0 @@ -// run-pass - -const I: std::iter::Empty<u32> = std::iter::empty(); - -fn main() { - for i in I { - panic!("magical value creation: {}", i); - } -} diff --git a/src/test/ui/consts/std/slice.rs b/src/test/ui/consts/std/slice.rs deleted file mode 100644 index f19defc64dd..00000000000 --- a/src/test/ui/consts/std/slice.rs +++ /dev/null @@ -1,10 +0,0 @@ -// build-pass (FIXME(62277): could be check-pass?) - -struct Wrap<T>(T); -unsafe impl<T> Send for Wrap<T> {} -unsafe impl<T> Sync for Wrap<T> {} - -static FOO: Wrap<*const u32> = Wrap([42, 44, 46].as_ptr()); -static BAR: Wrap<*const u8> = Wrap("hello".as_ptr()); - -fn main() {} |
