Skip to content

Commit 165768e

Browse files
committed
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 <[email protected]>
1 parent c525b05 commit 165768e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#[lang = "sized"]
2+
trait Sized {}
3+
4+
struct Foo<const N: usize>;
5+
6+
impl Foo<1> {
7+
fn call(&self) -> i32 {
8+
10
9+
}
10+
}
11+
12+
impl Foo<2> {
13+
fn call(&self) -> i32 {
14+
20
15+
}
16+
}
17+
18+
fn main() -> i32 {
19+
let a = Foo::<1> {};
20+
let b = Foo::<2> {};
21+
let aa = a.call();
22+
let bb = b.call();
23+
bb - aa - 10
24+
}

0 commit comments

Comments
 (0)