@@ -51,10 +51,7 @@ pub fn file_to_module_path(file_path: &str, src_dir: &Path) -> Vec<String> {
5151 . strip_prefix ( src_dir)
5252 . unwrap_or ( Path :: new ( file_path) ) ;
5353
54- let stem = relative
55- . file_stem ( )
56- . unwrap_or_default ( )
57- . to_string_lossy ( ) ;
54+ let stem = relative. file_stem ( ) . unwrap_or_default ( ) . to_string_lossy ( ) ;
5855
5956 let mut parts: Vec < String > = relative
6057 . parent ( )
@@ -176,11 +173,7 @@ pub fn add_extern_exports(
176173 // Short form: crate::fn_name (for crate-scoped matching)
177174 let short_key = format ! ( "{crate_name}::{fn_name}" ) ;
178175 if short_key != key {
179- export_map
180- . exports
181- . entry ( short_key)
182- . or_default ( )
183- . push ( auth) ;
176+ export_map. exports . entry ( short_key) . or_default ( ) . push ( auth) ;
184177 }
185178 }
186179 }
@@ -282,17 +275,26 @@ mod tests {
282275
283276 #[ test]
284277 fn file_to_module_path_lib ( ) {
285- assert_eq ! ( file_to_module_path( "src/lib.rs" , Path :: new( "src" ) ) , Vec :: <String >:: new( ) ) ;
278+ assert_eq ! (
279+ file_to_module_path( "src/lib.rs" , Path :: new( "src" ) ) ,
280+ Vec :: <String >:: new( )
281+ ) ;
286282 }
287283
288284 #[ test]
289285 fn file_to_module_path_main ( ) {
290- assert_eq ! ( file_to_module_path( "src/main.rs" , Path :: new( "src" ) ) , Vec :: <String >:: new( ) ) ;
286+ assert_eq ! (
287+ file_to_module_path( "src/main.rs" , Path :: new( "src" ) ) ,
288+ Vec :: <String >:: new( )
289+ ) ;
291290 }
292291
293292 #[ test]
294293 fn file_to_module_path_simple_module ( ) {
295- assert_eq ! ( file_to_module_path( "src/fs.rs" , Path :: new( "src" ) ) , vec![ "fs" ] ) ;
294+ assert_eq ! (
295+ file_to_module_path( "src/fs.rs" , Path :: new( "src" ) ) ,
296+ vec![ "fs" ]
297+ ) ;
296298 }
297299
298300 #[ test]
@@ -305,12 +307,21 @@ mod tests {
305307
306308 #[ test]
307309 fn file_to_module_path_mod_rs ( ) {
308- assert_eq ! ( file_to_module_path( "src/fs/mod.rs" , Path :: new( "src" ) ) , vec![ "fs" ] ) ;
310+ assert_eq ! (
311+ file_to_module_path( "src/fs/mod.rs" , Path :: new( "src" ) ) ,
312+ vec![ "fs" ]
313+ ) ;
309314 }
310315
311316 #[ test]
312317 fn build_export_map_basic ( ) {
313- let findings = vec ! [ make_finding( "src/lib.rs" , "read_file" , "std::fs::read" , Category :: Fs , false ) ] ;
318+ let findings = vec ! [ make_finding(
319+ "src/lib.rs" ,
320+ "read_file" ,
321+ "std::fs::read" ,
322+ Category :: Fs ,
323+ false ,
324+ ) ] ;
314325 let map = build_export_map ( "my_crate" , "1.0.0" , & findings, Path :: new ( "src" ) ) ;
315326 assert ! ( map. exports. contains_key( "my_crate::read_file" ) ) ;
316327 let auths = & map. exports [ "my_crate::read_file" ] ;
@@ -321,7 +332,13 @@ mod tests {
321332 #[ test]
322333 fn build_export_map_excludes_build_script ( ) {
323334 let findings = vec ! [
324- make_finding( "src/lib.rs" , "read_file" , "std::fs::read" , Category :: Fs , false ) ,
335+ make_finding(
336+ "src/lib.rs" ,
337+ "read_file" ,
338+ "std::fs::read" ,
339+ Category :: Fs ,
340+ false ,
341+ ) ,
325342 make_finding( "build.rs" , "main" , "std::env::var" , Category :: Env , true ) ,
326343 ] ;
327344 let map = build_export_map ( "my_crate" , "1.0.0" , & findings, Path :: new ( "src" ) ) ;
@@ -346,7 +363,13 @@ mod tests {
346363 fn build_export_map_multiple_findings_same_function ( ) {
347364 let findings = vec ! [
348365 make_finding( "src/lib.rs" , "mixed" , "std::fs::read" , Category :: Fs , false ) ,
349- make_finding( "src/lib.rs" , "mixed" , "TcpStream::connect" , Category :: Net , false ) ,
366+ make_finding(
367+ "src/lib.rs" ,
368+ "mixed" ,
369+ "TcpStream::connect" ,
370+ Category :: Net ,
371+ false ,
372+ ) ,
350373 ] ;
351374 let map = build_export_map ( "my_crate" , "1.0.0" , & findings, Path :: new ( "src" ) ) ;
352375 let auths = & map. exports [ "my_crate::mixed" ] ;
@@ -361,7 +384,13 @@ mod tests {
361384
362385 #[ test]
363386 fn cached_export_map_round_trip ( ) {
364- let findings = vec ! [ make_finding( "src/lib.rs" , "read_file" , "std::fs::read" , Category :: Fs , false ) ] ;
387+ let findings = vec ! [ make_finding(
388+ "src/lib.rs" ,
389+ "read_file" ,
390+ "std::fs::read" ,
391+ Category :: Fs ,
392+ false ,
393+ ) ] ;
365394 let export_map = build_export_map ( "my_crate" , "1.0.0" , & findings, Path :: new ( "src" ) ) ;
366395 let cached = CachedExportMap {
367396 schema_version : EXPORT_MAP_SCHEMA_VERSION ,
@@ -371,6 +400,11 @@ mod tests {
371400 let loaded: CachedExportMap = serde_json:: from_str ( & json) . unwrap ( ) ;
372401 assert_eq ! ( loaded. schema_version, EXPORT_MAP_SCHEMA_VERSION ) ;
373402 assert_eq ! ( loaded. export_map. crate_name, "my_crate" ) ;
374- assert ! ( loaded. export_map. exports. contains_key( "my_crate::read_file" ) ) ;
403+ assert ! (
404+ loaded
405+ . export_map
406+ . exports
407+ . contains_key( "my_crate::read_file" )
408+ ) ;
375409 }
376410}
0 commit comments