summaryrefslogtreecommitdiffstats
path: root/tests/ui/transmutability
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
commit837b550238aa671a591ccf282dddeab29cadb206 (patch)
tree914b6b8862bace72bd3245ca184d374b08d8a672 /tests/ui/transmutability
parentAdding debian version 1.70.0+dfsg2-1. (diff)
downloadrustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz
rustc-837b550238aa671a591ccf282dddeab29cadb206.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/transmutability')
-rw-r--r--tests/ui/transmutability/issue-110467.rs17
-rw-r--r--tests/ui/transmutability/references.current.stderr4
-rw-r--r--tests/ui/transmutability/references.next.stderr4
-rw-r--r--tests/ui/transmutability/region-infer.rs22
-rw-r--r--tests/ui/transmutability/region-infer.stderr23
5 files changed, 66 insertions, 4 deletions
diff --git a/tests/ui/transmutability/issue-110467.rs b/tests/ui/transmutability/issue-110467.rs
new file mode 100644
index 000000000..358733b98
--- /dev/null
+++ b/tests/ui/transmutability/issue-110467.rs
@@ -0,0 +1,17 @@
+// check-pass
+#![crate_type = "lib"]
+#![feature(transmutability)]
+use std::mem::BikeshedIntrinsicFrom;
+pub struct Context;
+
+pub fn is_maybe_transmutable<Src, Dst>()
+where
+ Dst: BikeshedIntrinsicFrom<Src, Context>,
+{
+}
+
+// The `T` here should not have any effect on checking
+// if transmutability is allowed or not.
+fn function_with_generic<T>() {
+ is_maybe_transmutable::<(), ()>();
+}
diff --git a/tests/ui/transmutability/references.current.stderr b/tests/ui/transmutability/references.current.stderr
index ecb095354..819c9b92b 100644
--- a/tests/ui/transmutability/references.current.stderr
+++ b/tests/ui/transmutability/references.current.stderr
@@ -1,8 +1,8 @@
-error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`
+error[E0277]: `&Unit` cannot be safely transmuted into `&Unit` in the defining scope of `assert::Context`
--> $DIR/references.rs:29:52
|
LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>();
- | ^^^^^^^^^^^^^ `&'static Unit` does not have a well-specified layout
+ | ^^^^^^^^^^^^^ `&Unit` does not have a well-specified layout
|
note: required by a bound in `is_maybe_transmutable`
--> $DIR/references.rs:16:14
diff --git a/tests/ui/transmutability/references.next.stderr b/tests/ui/transmutability/references.next.stderr
index ecb095354..819c9b92b 100644
--- a/tests/ui/transmutability/references.next.stderr
+++ b/tests/ui/transmutability/references.next.stderr
@@ -1,8 +1,8 @@
-error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`
+error[E0277]: `&Unit` cannot be safely transmuted into `&Unit` in the defining scope of `assert::Context`
--> $DIR/references.rs:29:52
|
LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>();
- | ^^^^^^^^^^^^^ `&'static Unit` does not have a well-specified layout
+ | ^^^^^^^^^^^^^ `&Unit` does not have a well-specified layout
|
note: required by a bound in `is_maybe_transmutable`
--> $DIR/references.rs:16:14
diff --git a/tests/ui/transmutability/region-infer.rs b/tests/ui/transmutability/region-infer.rs
new file mode 100644
index 000000000..09f602776
--- /dev/null
+++ b/tests/ui/transmutability/region-infer.rs
@@ -0,0 +1,22 @@
+#![feature(transmutability)]
+
+use std::mem::{Assume, BikeshedIntrinsicFrom};
+pub struct Context;
+
+#[repr(C)]
+struct W<'a>(&'a ());
+
+fn test<'a>()
+where
+ W<'a>: BikeshedIntrinsicFrom<
+ (),
+ Context,
+ { Assume { alignment: true, lifetimes: true, safety: true, validity: true } },
+ >,
+{
+}
+
+fn main() {
+ test();
+ //~^ ERROR `()` cannot be safely transmuted into `W<'_>`
+}
diff --git a/tests/ui/transmutability/region-infer.stderr b/tests/ui/transmutability/region-infer.stderr
new file mode 100644
index 000000000..d6b65e9e4
--- /dev/null
+++ b/tests/ui/transmutability/region-infer.stderr
@@ -0,0 +1,23 @@
+error[E0277]: `()` cannot be safely transmuted into `W<'_>` in the defining scope of `Context`
+ --> $DIR/region-infer.rs:20:5
+ |
+LL | test();
+ | ^^^^ `W<'_>` does not have a well-specified layout
+ |
+note: required by a bound in `test`
+ --> $DIR/region-infer.rs:11:12
+ |
+LL | fn test<'a>()
+ | ---- required by a bound in this function
+LL | where
+LL | W<'a>: BikeshedIntrinsicFrom<
+ | ____________^
+LL | | (),
+LL | | Context,
+LL | | { Assume { alignment: true, lifetimes: true, safety: true, validity: true } },
+LL | | >,
+ | |_________^ required by this bound in `test`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.