summaryrefslogtreecommitdiffstats
path: root/tests/ui/packed
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/packed')
-rw-r--r--tests/ui/packed/issue-27060-rpass.rs23
-rw-r--r--tests/ui/packed/issue-27060-rpass.stderr68
-rw-r--r--tests/ui/packed/issue-27060.rs4
-rw-r--r--tests/ui/packed/issue-27060.stderr76
-rw-r--r--tests/ui/packed/packed-struct-borrow-element-64bit.rs5
-rw-r--r--tests/ui/packed/packed-struct-borrow-element-64bit.stderr31
-rw-r--r--tests/ui/packed/packed-struct-borrow-element.rs8
-rw-r--r--tests/ui/packed/packed-struct-borrow-element.stderr54
8 files changed, 21 insertions, 248 deletions
diff --git a/tests/ui/packed/issue-27060-rpass.rs b/tests/ui/packed/issue-27060-rpass.rs
deleted file mode 100644
index d9159f666..000000000
--- a/tests/ui/packed/issue-27060-rpass.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#[repr(packed)]
-pub struct Good {
- data: &'static u32,
- data2: [&'static u32; 2],
- aligned: [u8; 32],
-}
-
-// kill this test when that turns to a hard error
-#[allow(unaligned_references)]
-fn main() {
- let good = Good { data: &0, data2: [&0, &0], aligned: [0; 32] };
-
- let _ = &good.data; // ok
- let _ = &good.data2[0]; // ok
-
- let _ = &good.data;
- let _ = &good.data2[0];
- let _ = &*good.data; // ok, behind a pointer
- let _ = &good.aligned; // ok, has align 1
- let _ = &good.aligned[2]; // ok, has align 1
-}
diff --git a/tests/ui/packed/issue-27060-rpass.stderr b/tests/ui/packed/issue-27060-rpass.stderr
deleted file mode 100644
index adf9ae9f5..000000000
--- a/tests/ui/packed/issue-27060-rpass.stderr
+++ /dev/null
@@ -1,68 +0,0 @@
-Future incompatibility report: Future breakage diagnostic:
-warning: reference to packed field is unaligned
- --> $DIR/issue-27060-rpass.rs:15:13
- |
-LL | let _ = &good.data; // ok
- | ^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-note: the lint level is defined here
- --> $DIR/issue-27060-rpass.rs:11:9
- |
-LL | #[allow(unaligned_references)]
- | ^^^^^^^^^^^^^^^^^^^^
-
-Future breakage diagnostic:
-warning: reference to packed field is unaligned
- --> $DIR/issue-27060-rpass.rs:16:13
- |
-LL | let _ = &good.data2[0]; // ok
- | ^^^^^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-note: the lint level is defined here
- --> $DIR/issue-27060-rpass.rs:11:9
- |
-LL | #[allow(unaligned_references)]
- | ^^^^^^^^^^^^^^^^^^^^
-
-Future breakage diagnostic:
-warning: reference to packed field is unaligned
- --> $DIR/issue-27060-rpass.rs:18:13
- |
-LL | let _ = &good.data;
- | ^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-note: the lint level is defined here
- --> $DIR/issue-27060-rpass.rs:11:9
- |
-LL | #[allow(unaligned_references)]
- | ^^^^^^^^^^^^^^^^^^^^
-
-Future breakage diagnostic:
-warning: reference to packed field is unaligned
- --> $DIR/issue-27060-rpass.rs:19:13
- |
-LL | let _ = &good.data2[0];
- | ^^^^^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-note: the lint level is defined here
- --> $DIR/issue-27060-rpass.rs:11:9
- |
-LL | #[allow(unaligned_references)]
- | ^^^^^^^^^^^^^^^^^^^^
-
diff --git a/tests/ui/packed/issue-27060.rs b/tests/ui/packed/issue-27060.rs
index 886a00239..a0e944caa 100644
--- a/tests/ui/packed/issue-27060.rs
+++ b/tests/ui/packed/issue-27060.rs
@@ -13,14 +13,10 @@ fn main() {
};
let _ = &good.data; //~ ERROR reference to packed field
- //~| hard error
let _ = &good.data2[0]; //~ ERROR reference to packed field
- //~| hard error
let _ = &good.data; //~ ERROR reference to packed field
- //~| hard error
let _ = &good.data2[0]; //~ ERROR reference to packed field
- //~| hard error
let _ = &*good.data; // ok, behind a pointer
let _ = &good.aligned; // ok, has align 1
let _ = &good.aligned[2]; // ok, has align 1
diff --git a/tests/ui/packed/issue-27060.stderr b/tests/ui/packed/issue-27060.stderr
index 85e08fa02..b4753284f 100644
--- a/tests/ui/packed/issue-27060.stderr
+++ b/tests/ui/packed/issue-27060.stderr
@@ -1,99 +1,39 @@
-error: reference to packed field is unaligned
+error[E0793]: reference to packed field is unaligned
--> $DIR/issue-27060.rs:15:13
|
LL | let _ = &good.data;
| ^^^^^^^^^^
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
- = note: `#[deny(unaligned_references)]` on by default
-error: reference to packed field is unaligned
- --> $DIR/issue-27060.rs:17:13
+error[E0793]: reference to packed field is unaligned
+ --> $DIR/issue-27060.rs:16:13
|
LL | let _ = &good.data2[0];
| ^^^^^^^^^^^^^^
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-error: reference to packed field is unaligned
- --> $DIR/issue-27060.rs:20:13
+error[E0793]: reference to packed field is unaligned
+ --> $DIR/issue-27060.rs:18:13
|
LL | let _ = &good.data;
| ^^^^^^^^^^
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-error: reference to packed field is unaligned
- --> $DIR/issue-27060.rs:22:13
+error[E0793]: reference to packed field is unaligned
+ --> $DIR/issue-27060.rs:19:13
|
LL | let _ = &good.data2[0];
| ^^^^^^^^^^^^^^
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error: aborting due to 4 previous errors
-Future incompatibility report: Future breakage diagnostic:
-error: reference to packed field is unaligned
- --> $DIR/issue-27060.rs:15:13
- |
-LL | let _ = &good.data;
- | ^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
- = note: `#[deny(unaligned_references)]` on by default
-
-Future breakage diagnostic:
-error: reference to packed field is unaligned
- --> $DIR/issue-27060.rs:17:13
- |
-LL | let _ = &good.data2[0];
- | ^^^^^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
- = note: `#[deny(unaligned_references)]` on by default
-
-Future breakage diagnostic:
-error: reference to packed field is unaligned
- --> $DIR/issue-27060.rs:20:13
- |
-LL | let _ = &good.data;
- | ^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
- = note: `#[deny(unaligned_references)]` on by default
-
-Future breakage diagnostic:
-error: reference to packed field is unaligned
- --> $DIR/issue-27060.rs:22:13
- |
-LL | let _ = &good.data2[0];
- | ^^^^^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
- = note: `#[deny(unaligned_references)]` on by default
-
+For more information about this error, try `rustc --explain E0793`.
diff --git a/tests/ui/packed/packed-struct-borrow-element-64bit.rs b/tests/ui/packed/packed-struct-borrow-element-64bit.rs
index 00bddfe40..63315ea66 100644
--- a/tests/ui/packed/packed-struct-borrow-element-64bit.rs
+++ b/tests/ui/packed/packed-struct-borrow-element-64bit.rs
@@ -1,4 +1,3 @@
-// run-pass (note: this is spec-UB, but it works for now)
// ignore-32bit (needs `usize` to be 8-aligned to reproduce all the errors below)
#![allow(dead_code)]
// ignore-emscripten weird assertion?
@@ -9,10 +8,8 @@ struct Foo4C {
baz: usize
}
-#[warn(unaligned_references)]
pub fn main() {
let foo = Foo4C { bar: 1, baz: 2 };
- let brw = &foo.baz; //~WARN reference to packed field is unaligned
- //~^ previously accepted
+ let brw = &foo.baz; //~ERROR reference to packed field is unaligned
assert_eq!(*brw, 2);
}
diff --git a/tests/ui/packed/packed-struct-borrow-element-64bit.stderr b/tests/ui/packed/packed-struct-borrow-element-64bit.stderr
index fb2f5615c..32943b0f0 100644
--- a/tests/ui/packed/packed-struct-borrow-element-64bit.stderr
+++ b/tests/ui/packed/packed-struct-borrow-element-64bit.stderr
@@ -1,35 +1,12 @@
-warning: reference to packed field is unaligned
- --> $DIR/packed-struct-borrow-element-64bit.rs:15:15
+error[E0793]: reference to packed field is unaligned
+ --> $DIR/packed-struct-borrow-element-64bit.rs:13:15
|
LL | let brw = &foo.baz;
| ^^^^^^^^
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-note: the lint level is defined here
- --> $DIR/packed-struct-borrow-element-64bit.rs:12:8
- |
-LL | #[warn(unaligned_references)]
- | ^^^^^^^^^^^^^^^^^^^^
-
-warning: 1 warning emitted
-Future incompatibility report: Future breakage diagnostic:
-warning: reference to packed field is unaligned
- --> $DIR/packed-struct-borrow-element-64bit.rs:15:15
- |
-LL | let brw = &foo.baz;
- | ^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-note: the lint level is defined here
- --> $DIR/packed-struct-borrow-element-64bit.rs:12:8
- |
-LL | #[warn(unaligned_references)]
- | ^^^^^^^^^^^^^^^^^^^^
+error: aborting due to previous error
+For more information about this error, try `rustc --explain E0793`.
diff --git a/tests/ui/packed/packed-struct-borrow-element.rs b/tests/ui/packed/packed-struct-borrow-element.rs
index a6ee90cef..6cbeca44b 100644
--- a/tests/ui/packed/packed-struct-borrow-element.rs
+++ b/tests/ui/packed/packed-struct-borrow-element.rs
@@ -1,4 +1,3 @@
-// run-pass (note: this is spec-UB, but it works for now)
#![allow(dead_code)]
// ignore-emscripten weird assertion?
@@ -20,15 +19,12 @@ struct Foo4C {
baz: usize
}
-#[warn(unaligned_references)]
pub fn main() {
let foo = Foo1 { bar: 1, baz: 2 };
- let brw = &foo.baz; //~WARN reference to packed field is unaligned
- //~^ previously accepted
+ let brw = &foo.baz; //~ERROR reference to packed field is unaligned
assert_eq!(*brw, 2);
let foo = Foo2 { bar: 1, baz: 2 };
- let brw = &foo.baz; //~WARN reference to packed field is unaligned
- //~^ previously accepted
+ let brw = &foo.baz; //~ERROR reference to packed field is unaligned
assert_eq!(*brw, 2);
}
diff --git a/tests/ui/packed/packed-struct-borrow-element.stderr b/tests/ui/packed/packed-struct-borrow-element.stderr
index 75d55c4f6..29d867fc5 100644
--- a/tests/ui/packed/packed-struct-borrow-element.stderr
+++ b/tests/ui/packed/packed-struct-borrow-element.stderr
@@ -1,63 +1,21 @@
-warning: reference to packed field is unaligned
- --> $DIR/packed-struct-borrow-element.rs:26:15
+error[E0793]: reference to packed field is unaligned
+ --> $DIR/packed-struct-borrow-element.rs:24:15
|
LL | let brw = &foo.baz;
| ^^^^^^^^
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-note: the lint level is defined here
- --> $DIR/packed-struct-borrow-element.rs:23:8
- |
-LL | #[warn(unaligned_references)]
- | ^^^^^^^^^^^^^^^^^^^^
-warning: reference to packed field is unaligned
- --> $DIR/packed-struct-borrow-element.rs:31:15
+error[E0793]: reference to packed field is unaligned
+ --> $DIR/packed-struct-borrow-element.rs:28:15
|
LL | let brw = &foo.baz;
| ^^^^^^^^
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-warning: 2 warnings emitted
-
-Future incompatibility report: Future breakage diagnostic:
-warning: reference to packed field is unaligned
- --> $DIR/packed-struct-borrow-element.rs:26:15
- |
-LL | let brw = &foo.baz;
- | ^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-note: the lint level is defined here
- --> $DIR/packed-struct-borrow-element.rs:23:8
- |
-LL | #[warn(unaligned_references)]
- | ^^^^^^^^^^^^^^^^^^^^
-
-Future breakage diagnostic:
-warning: reference to packed field is unaligned
- --> $DIR/packed-struct-borrow-element.rs:31:15
- |
-LL | let brw = &foo.baz;
- | ^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
- = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-note: the lint level is defined here
- --> $DIR/packed-struct-borrow-element.rs:23:8
- |
-LL | #[warn(unaligned_references)]
- | ^^^^^^^^^^^^^^^^^^^^
+error: aborting due to 2 previous errors
+For more information about this error, try `rustc --explain E0793`.