Skip to content

Commit f0be261

Browse files
committed
tests/statics: tolerate --reorganize-definitions output
1 parent f5024f8 commit f0be261

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/statics/src/test_sections.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ pub fn test_sectioned_used_static() {
3636
// directly at the source file
3737
let src = include_str!("attributes.rs");
3838

39-
let lines: Vec<&str> = src.lines().collect();
39+
let mut lines: Vec<&str> = src.lines().collect();
40+
41+
// Remove the c2rust::src_loc annotation, which is only produced if
42+
// --reorganize-definitions is enabled.
43+
lines.retain(|x| !x.contains("#[c2rust::src_loc"));
44+
let src = lines.join("\n");
4045

4146
let pos = lines
4247
.iter()
@@ -52,6 +57,8 @@ pub fn test_sectioned_used_static() {
5257

5358
// This static is pub, but we want to ensure it has attributes applied
5459
assert!(src.contains("#[link_section = \"fb\"]\npub static mut rust_initialized_extern: ::core::ffi::c_int = 1 as ::core::ffi::c_int;"));
55-
assert!(src.contains("extern \"C\" {\n #[link_name = \"no_attrs\"]\n static mut rust_aliased_static: ::core::ffi::c_int;"))
60+
// This static is pub only with --reorganize-definitions
61+
let aliased_static_syntax = |public| format!("extern \"C\" {{\n #[link_name = \"no_attrs\"]\n {}static mut rust_aliased_static: ::core::ffi::c_int;", public);
62+
assert!(src.contains(&aliased_static_syntax("")) || src.contains(&aliased_static_syntax("pub ")))
5663
}
5764
}

0 commit comments

Comments
 (0)