]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add test case showing method resolution with const-generics
authorPhilip Herron <herron.philip@googlemail.com>
Fri, 1 Aug 2025 20:54:36 +0000 (21:54 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:37:02 +0000 (16:37 +0200)
gcc/testsuite/ChangeLog:

* rust/execute/torture/const-generics-1.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/testsuite/rust/execute/torture/const-generics-1.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/execute/torture/const-generics-1.rs b/gcc/testsuite/rust/execute/torture/const-generics-1.rs
new file mode 100644 (file)
index 0000000..dbb7afe
--- /dev/null
@@ -0,0 +1,24 @@
+#[lang = "sized"]
+trait Sized {}
+
+struct Foo<const N: usize>;
+
+impl Foo<1> {
+    fn call(&self) -> i32 {
+        10
+    }
+}
+
+impl Foo<2> {
+    fn call(&self) -> i32 {
+        20
+    }
+}
+
+fn main() -> i32 {
+    let a = Foo::<1> {};
+    let b = Foo::<2> {};
+    let aa = a.call();
+    let bb = b.call();
+    bb - aa - 10
+}