From 14c4c2f142d1908e8e93aa15d49f61f97f060727 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Mon, 20 May 2024 13:29:51 +0200 Subject: [PATCH] Add two new tests related to may_dangle attribute 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 --- .../rust/compile/dropck_eyepatch_feature_gate.rs | 8 ++++++++ gcc/testsuite/rust/compile/may_dangle.rs | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/rust/compile/dropck_eyepatch_feature_gate.rs create mode 100644 gcc/testsuite/rust/compile/may_dangle.rs 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 index 000000000000..3c3174f93bba --- /dev/null +++ b/gcc/testsuite/rust/compile/dropck_eyepatch_feature_gate.rs @@ -0,0 +1,8 @@ +// { dg-options "-frust-compile-until=lowering" } +struct Test { + _inner: T, +} + +trait Action {} + +unsafe impl<#[may_dangle] T> Action for Test {} //{ 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 index 000000000000..6b81b53aa596 --- /dev/null +++ b/gcc/testsuite/rust/compile/may_dangle.rs @@ -0,0 +1,10 @@ +// { dg-options "-fsyntax-only" } + +#![feature(dropck_eyepatch)] +struct Test { + _inner: T, +} + +trait Action {} + +unsafe impl<#[may_dangle] T> Action for Test {}