Skip to content

Commit cbfd8f2

Browse files
committed
tests/items: tolerate --reorganize-definitions output
1 parent f0be261 commit cbfd8f2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/items/src/test_fn_attrs.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ pub fn test_fn_attrs() {
66
// so instead we're checking the source itself
77
let src = include_str!("fn_attrs.rs");
88

9+
// Remove the c2rust::src_loc annotation, which is only produced if
10+
// --reorganize-definitions is enabled.
11+
let mut lines: Vec<&str> = src.lines().collect();
12+
lines.retain(|x| !x.contains("#[c2rust::src_loc"));
13+
let src = lines.join("\n");
14+
915
// Some C99 rules for convenience:
1016
// * In C99, a function defined inline will never, and a function defined extern inline
1117
// will always, emit an externally visible function.
@@ -57,8 +63,7 @@ pub fn test_fn_attrs() {
5763

5864
if cfg!(not(target_os = "macos")) {
5965
// aliased_fn is aliased to the inline_extern function
60-
assert!(src.contains(
61-
"extern \"C\" {\n #[link_name = \"inline_extern\"]\n fn aliased_fn();"
62-
));
66+
let aliased_fn_syntax = |public| format!("extern \"C\" {{\n #[link_name = \"inline_extern\"]\n {}fn aliased_fn();", public);
67+
assert!(src.contains(&aliased_fn_syntax("")) || src.contains(&aliased_fn_syntax("pub ")));
6368
}
6469
}

0 commit comments

Comments
 (0)