]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add two new tests related to may_dangle attribute
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 20 May 2024 11:29:51 +0000 (13:29 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 17 Mar 2025 15:35:32 +0000 (16:35 +0100)
First test checks the may_dangle outer atttribute on generic params can
be parsed. The second one tests whether may_dangle attributes are
correctly feature gated.

gcc/testsuite/ChangeLog:

* rust/compile/dropck_eyepatch_feature_gate.rs: New test.
* rust/compile/may_dangle.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/testsuite/rust/compile/dropck_eyepatch_feature_gate.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/may_dangle.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/compile/dropck_eyepatch_feature_gate.rs b/gcc/testsuite/rust/compile/dropck_eyepatch_feature_gate.rs
new file mode 100644 (file)
index 0000000..3c3174f
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-options "-frust-compile-until=lowering" }
+struct Test<T> {
+    _inner: T,
+}
+
+trait Action {}
+
+unsafe impl<#[may_dangle] T> Action for Test<T> {} //{ dg-error ".may_dangle. has unstable semantics and may be removed in the future." "" { target *-*-* }  }
diff --git a/gcc/testsuite/rust/compile/may_dangle.rs b/gcc/testsuite/rust/compile/may_dangle.rs
new file mode 100644 (file)
index 0000000..6b81b53
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-options "-fsyntax-only" }
+
+#![feature(dropck_eyepatch)]
+struct Test<T> {
+    _inner: T,
+}
+
+trait Action {}
+
+unsafe impl<#[may_dangle] T> Action for Test<T> {}