Skip to content

Commit c1d8892

Browse files
committed
fmt
1 parent 8663bbe commit c1d8892

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/tools/run-make-support/src/symbols.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::path::Path;
22

3-
use object::{self, Object, Symbol, ObjectSymbol, SymbolIterator};
3+
use object::{self, Object, ObjectSymbol, Symbol, SymbolIterator};
44

55
/// Iterate through the symbols in an object file.
66
///
@@ -50,7 +50,11 @@ pub fn any_symbol_contains(path: impl AsRef<Path>, substrings: &[&str]) -> bool
5050
/// The symbol names must match exactly.
5151
///
5252
/// Panics if `path` is not a valid object file readable by the current user.
53-
pub fn missing_exact_symbols<'a>(path: impl AsRef<Path>, symbol_names: &[&'a str], pred: impl Fn(&Symbol<'_, '_>) -> bool) -> Vec<&'a str> {
53+
pub fn missing_exact_symbols<'a>(
54+
path: impl AsRef<Path>,
55+
symbol_names: &[&'a str],
56+
pred: impl Fn(&Symbol<'_, '_>) -> bool,
57+
) -> Vec<&'a str> {
5458
let mut found = vec![false; symbol_names.len()];
5559
with_symbol_iter(path, |syms| {
5660
for sym in syms.filter(&pred) {
@@ -59,16 +63,19 @@ pub fn missing_exact_symbols<'a>(path: impl AsRef<Path>, symbol_names: &[&'a str
5963
}
6064
}
6165
});
62-
return found.iter().enumerate()
63-
.filter_map(|(i, found)| if !*found {
64-
Some(symbol_names[i])
65-
} else {
66-
None
67-
}).collect();
66+
return found
67+
.iter()
68+
.enumerate()
69+
.filter_map(|(i, found)| if !*found { Some(symbol_names[i]) } else { None })
70+
.collect();
6871
}
6972

7073
/// Assert that the symbol file contains all of the listed symbols and they all match the given predicate
71-
pub fn assert_contains_exact_symbols(path: impl AsRef<Path>, symbol_names: &[&str], pred: impl Fn(&Symbol<'_, '_>) -> bool) {
74+
pub fn assert_contains_exact_symbols(
75+
path: impl AsRef<Path>,
76+
symbol_names: &[&str],
77+
pred: impl Fn(&Symbol<'_, '_>) -> bool,
78+
) {
7279
let missing = missing_exact_symbols(path.as_ref(), symbol_names, pred);
7380
if missing.len() > 0 {
7481
eprintln!("{} does not contain symbol(s): ", path.as_ref().display());
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
//@ ignore-cross-compile
2+
use run_make_support::object::ObjectSymbol;
23
use run_make_support::rustc;
34
use run_make_support::symbols::assert_contains_exact_symbols;
4-
use run_make_support::object::ObjectSymbol;
55
fn main() {
66
rustc().input("dylib.rs").output("dylib.so").prefer_dynamic().run();
7-
assert_contains_exact_symbols(
8-
"dylib.so",
9-
&["fun1", "fun2", "fun3", "fun4", "fun5"],
10-
|sym| dbg!(dbg!(sym).is_global()) && !dbg!(sym.is_undefined()),
11-
);
7+
assert_contains_exact_symbols("dylib.so", &["fun1", "fun2", "fun3", "fun4", "fun5"], |sym| {
8+
dbg!(dbg!(sym).is_global()) && !dbg!(sym.is_undefined())
9+
});
1210
}

0 commit comments

Comments
 (0)