summaryrefslogtreecommitdiffstats
path: root/tests/ui/transmute/lifetimes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/transmute/lifetimes.rs')
-rw-r--r--tests/ui/transmute/lifetimes.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/transmute/lifetimes.rs b/tests/ui/transmute/lifetimes.rs
new file mode 100644
index 000000000..943191551
--- /dev/null
+++ b/tests/ui/transmute/lifetimes.rs
@@ -0,0 +1,23 @@
+// check-pass
+
+use std::ptr::NonNull;
+
+struct Foo<'a, T: ?Sized>(&'a (), NonNull<T>);
+
+fn foo<'a, 'b, T: ?Sized>(x: Foo<'a, T>) -> Foo<'b, T> {
+ unsafe { std::mem::transmute(x) }
+}
+
+struct Bar<'a, T: ?Sized>(&'a T);
+
+fn bar<'a, 'b, T: ?Sized>(x: Bar<'a, T>) -> Bar<'b, T> {
+ unsafe { std::mem::transmute(x) }
+}
+
+struct Boo<'a, T: ?Sized>(&'a T, u32);
+
+fn boo<'a, 'b, T: ?Sized>(x: Boo<'a, T>) -> Boo<'b, T> {
+ unsafe { std::mem::transmute(x) }
+}
+
+fn main() {}