aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-08-01 21:54:36 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-08-05 16:37:02 +0200
commit3d42d4fdf1a06da9d04c1f8ca4574def333f1c91 (patch)
tree56de0ab143e8e4e9b8aedda43f78f2c56be8630d
parent90070a8f4572d760f3e9fac4b1f7da815909fa59 (diff)
downloadgcc-3d42d4fdf1a06da9d04c1f8ca4574def333f1c91.zip
gcc-3d42d4fdf1a06da9d04c1f8ca4574def333f1c91.tar.gz
gcc-3d42d4fdf1a06da9d04c1f8ca4574def333f1c91.tar.bz2
gccrs: Add test case showing method resolution with const-generics
gcc/testsuite/ChangeLog: * rust/execute/torture/const-generics-1.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
-rw-r--r--gcc/testsuite/rust/execute/torture/const-generics-1.rs24
1 files changed, 24 insertions, 0 deletions
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
index 0000000..dbb7afe
--- /dev/null
+++ b/gcc/testsuite/rust/execute/torture/const-generics-1.rs
@@ -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
+}