Skip to content

Commit 4960c84

Browse files
randomPoisonthedataking
authored andcommitted
First pass regression test
1 parent e1c2970 commit 4960c84

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

c2rust-refactor/tests/snapshots.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,13 @@ fn test_reorganize_foreign_types() {
459459
.test();
460460
}
461461

462+
#[test]
463+
fn test_reorganize_forward_decl_with_local_definition() {
464+
refactor("reorganize_definitions")
465+
.named("reorganize_forward_decl_with_local_definition.rs")
466+
.test();
467+
}
468+
462469
#[test]
463470
fn test_sink_lets() {
464471
refactor("sink_lets").test();
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#![feature(extern_types)]
2+
#![feature(register_tool)]
3+
#![register_tool(c2rust)]
4+
#![allow(dead_code)]
5+
#![allow(non_camel_case_types)]
6+
7+
pub mod repository {
8+
#[c2rust::header_src = "attrcache.h:1"]
9+
pub mod attrcache_h {
10+
extern "C" {
11+
#[c2rust::src_loc = "1:1"]
12+
pub type git_attr_cache;
13+
}
14+
}
15+
16+
#[c2rust::header_src = "repository.h:2"]
17+
pub mod repository_h {
18+
pub use super::attrcache_h::git_attr_cache;
19+
20+
#[derive(Copy, Clone)]
21+
#[repr(C)]
22+
#[c2rust::src_loc = "2:1"]
23+
pub struct git_repository {
24+
pub attrcache: *mut git_attr_cache,
25+
}
26+
}
27+
28+
use repository_h::git_repository;
29+
}
30+
31+
pub mod attrcache {
32+
#[c2rust::header_src = "attrcache.h:1"]
33+
pub mod attrcache_h {
34+
#[c2rust::src_loc = "1:1"]
35+
pub const GIT_ATTR_CONFIG: i32 = 0;
36+
}
37+
38+
#[c2rust::header_src = "repository.h:2"]
39+
pub mod repository_h {
40+
use super::git_attr_cache;
41+
42+
#[derive(Copy, Clone)]
43+
#[repr(C)]
44+
#[c2rust::src_loc = "2:1"]
45+
pub struct git_repository {
46+
pub attrcache: *mut git_attr_cache,
47+
}
48+
49+
#[c2rust::src_loc = "3:1"]
50+
pub unsafe extern "C" fn git_repository_attr_cache(
51+
repo: *mut git_repository,
52+
) -> *mut git_attr_cache {
53+
(*repo).attrcache
54+
}
55+
}
56+
57+
use repository_h::git_repository;
58+
59+
#[derive(Copy, Clone)]
60+
#[repr(C)]
61+
pub struct git_attr_cache {
62+
pub x: i32,
63+
}
64+
65+
unsafe extern "C" fn attrcache_source_function(
66+
repo: *mut git_repository,
67+
) -> *mut git_attr_cache {
68+
repository_h::git_repository_attr_cache(repo)
69+
}
70+
}
71+
72+
fn main() {}

0 commit comments

Comments
 (0)