[COMMITTED,056/101] gccrs: Add regression test for const fn in trait

Message ID 20240130121026.807464-59-arthur.cohen@embecosm.com
State Committed
Commit ab257dcd66cd2532beb0c74b836147d02a9ed3bb
Headers
Series [COMMITTED,001/101] gccrs: Add visibility to trait item |

Commit Message

Arthur Cohen Jan. 30, 2024, 12:07 p.m. UTC
  From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Const fn declaration in trait declarations shall emit an error. This new
test highlight this behavior.

gcc/testsuite/ChangeLog:

	* rust/compile/const_trait_fn.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
---
 gcc/testsuite/rust/compile/const_trait_fn.rs | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/const_trait_fn.rs
  

Patch

diff --git a/gcc/testsuite/rust/compile/const_trait_fn.rs b/gcc/testsuite/rust/compile/const_trait_fn.rs
new file mode 100644
index 00000000000..cff2f5f096e
--- /dev/null
+++ b/gcc/testsuite/rust/compile/const_trait_fn.rs
@@ -0,0 +1,4 @@ 
+trait Osterkz {
+    const fn x();
+    // { dg-error "functions in traits cannot be declared const .E0379." "" { target *-*-* } .-1 }
+}