Skip to content

Commit 626bc09

Browse files
committed
gccrs: Add test case showing RPIT working to close issue
Fixes #1486 gcc/testsuite/ChangeLog: * rust/execute/torture/issue-1481.rs: New test. Signed-off-by: Philip Herron <[email protected]>
1 parent 98e07b3 commit 626bc09

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* { dg-output "called Foo::print\\(\\)\r*" } */
2+
/* { dg-options "-w" } */
3+
4+
#[lang = "sized"]
5+
trait Sized {}
6+
7+
trait Printable {
8+
fn print(&self);
9+
}
10+
11+
struct Foo;
12+
13+
impl Printable for Foo {
14+
fn print(&self) {
15+
// Simulate output
16+
unsafe {
17+
puts("called Foo::print()\0" as *const _ as *const i8);
18+
}
19+
}
20+
}
21+
22+
fn get_printable() -> impl Printable {
23+
Foo
24+
}
25+
26+
extern "C" {
27+
fn puts(s: *const i8);
28+
}
29+
30+
fn main() -> i32 {
31+
let p = get_printable();
32+
p.print();
33+
34+
0
35+
}

0 commit comments

Comments
 (0)