@@ -144,7 +144,7 @@ impl ProcessedData {
144144 }
145145
146146 pub fn finalized ( mut self , default_name : & str ) -> Self {
147- self . deduplicate_types ( & default_name) ;
147+ self . deduplicate_types ( default_name) ;
148148 // TODO: Run remap.
149149 self . prune ( )
150150 }
@@ -209,7 +209,7 @@ impl ProcessedData {
209209 merged_type_library. add_alternate_name ( alt_name) ;
210210 }
211211 for platform_name in & tl. platform_names ( ) {
212- if let Some ( platform) = Platform :: by_name ( & platform_name) {
212+ if let Some ( platform) = Platform :: by_name ( platform_name) {
213213 merged_type_library. add_platform ( & platform) ;
214214 } else {
215215 // TODO: Upgrade this to an error?
@@ -375,14 +375,13 @@ impl ProcessedData {
375375 for type_library in type_libraries {
376376 // If the default type library does not have the platform, it will not be pulled in.
377377 for platform_name in & type_library. platform_names ( ) {
378- if let Some ( platform) = Platform :: by_name ( & platform_name) {
378+ if let Some ( platform) = Platform :: by_name ( platform_name) {
379379 default_type_library. add_platform ( & platform) ;
380380 }
381381 }
382382
383383 type_library. remove_named_type ( qualified_name. clone ( ) ) ;
384- type_library
385- . add_type_source ( qualified_name. clone ( ) , & default_type_library_name) ;
384+ type_library. add_type_source ( qualified_name. clone ( ) , default_type_library_name) ;
386385 }
387386 } else {
388387 // TODO: Probably demote this to debug, since they might just be disparate types.
@@ -480,7 +479,7 @@ impl TypeLibProcessor {
480479
481480 pub fn process ( & self , path : & Path ) -> Result < ProcessedData , ProcessingError > {
482481 match path. extension ( ) {
483- Some ( ext) if ext == "bntl" => self . process_type_library ( & path) ,
482+ Some ( ext) if ext == "bntl" => self . process_type_library ( path) ,
484483 Some ( ext) if ext == "h" || ext == "hpp" => self . process_source ( path) ,
485484 // NOTE: A typical processor will not go down this path where we only provide a single
486485 // winmd file to be processed. You almost always want to process multiple winmd files,
@@ -603,18 +602,18 @@ impl TypeLibProcessor {
603602 project_file : & ProjectFile ,
604603 ) -> Result < ProcessedData , ProcessingError > {
605604 let file_name = project_file. name ( ) ;
606- let extension = file_name. split ( '.' ) . last ( ) ;
605+ let extension = file_name. split ( '.' ) . next_back ( ) ;
607606 let path = project_file
608607 . path_on_disk ( )
609608 . ok_or_else ( || ProcessingError :: NoPathToProjectFile ( project_file. to_owned ( ) ) ) ?;
610609 match extension {
611- Some ( ext ) if ext == "bntl" => self . process_type_library ( & path) ,
610+ Some ( "bntl" ) => self . process_type_library ( & path) ,
612611 Some ( ext) if ext == "h" || ext == "hpp" => self . process_source ( & path) ,
613612 // NOTE: A typical processor will not go down this path where we only provide a single
614613 // winmd file to be processed. You almost always want to process multiple winmd files,
615614 // which can be done by passing a directory with the relevant winmd files.
616- Some ( ext ) if ext == "winmd" => self . process_winmd ( & [ path] ) ,
617- Some ( ext ) if ext == "tbd" => self . process_tbd ( & path) ,
615+ Some ( "winmd" ) => self . process_winmd ( & [ path] ) ,
616+ Some ( "tbd" ) => self . process_tbd ( & path) ,
618617 _ => {
619618 // If the file cannot be parsed, it should be skipped to avoid a load error.
620619 if !is_parsable ( & path) {
@@ -623,7 +622,7 @@ impl TypeLibProcessor {
623622
624623 let settings_str = self . analysis_settings . to_string ( ) ;
625624 let file = binaryninja:: load_project_file_with_progress (
626- & project_file,
625+ project_file,
627626 false ,
628627 Some ( settings_str) ,
629628 |_pos, _total| {
@@ -654,7 +653,7 @@ impl TypeLibProcessor {
654653
655654 let settings_str = self . analysis_settings . to_string ( ) ;
656655 let file = binaryninja:: load_with_options_and_progress (
657- & path,
656+ path,
658657 false ,
659658 Some ( settings_str) ,
660659 |_pos, _total| {
@@ -800,10 +799,10 @@ impl TypeLibProcessor {
800799 type_library. store_metadata ( "ordinals_10_0" , & map_md) ;
801800 }
802801
803- let mut processed_data = self . process_external_libraries ( & view) ?;
802+ let mut processed_data = self . process_external_libraries ( view) ?;
804803 processed_data. type_libraries . insert ( type_library) ;
805804 if let Some ( api_set_section) = view. section_by_name ( ".apiset" ) {
806- let processed_api_set = self . process_api_set ( & view, & api_set_section) ?;
805+ let processed_api_set = self . process_api_set ( view, & api_set_section) ?;
807806 tracing:: info!(
808807 "Found {} api set libraries in '{}', adding alternative names..." ,
809808 processed_api_set. type_libraries. len( ) ,
@@ -905,7 +904,7 @@ impl TypeLibProcessor {
905904 let section_bytes = view
906905 . read_buffer ( section. start ( ) , section. len ( ) )
907906 . ok_or_else ( || ProcessingError :: BinaryViewRead ( section. start ( ) , section. len ( ) ) ) ?;
908- let api_set_map = ApiSetMap :: try_from_apiset_section_bytes ( & section_bytes. get_data ( ) ) ?;
907+ let api_set_map = ApiSetMap :: try_from_apiset_section_bytes ( section_bytes. get_data ( ) ) ?;
909908
910909 let mut target_map: HashMap < String , HashSet < String > > = HashMap :: new ( ) ;
911910 for entry in api_set_map. namespace_entries ( ) ? {
@@ -944,7 +943,7 @@ impl TypeLibProcessor {
944943 /// during the [`ProcessedData::merge`] step. This lets us add overrides like extra platforms.
945944 pub fn process_type_library ( & self , path : & Path ) -> Result < ProcessedData , ProcessingError > {
946945 self . state . set_file_state ( path. to_owned ( ) , false ) ;
947- let finalized_type_library = TypeLibrary :: load_from_file ( & path)
946+ let finalized_type_library = TypeLibrary :: load_from_file ( path)
948947 . ok_or_else ( || ProcessingError :: InvalidTypeLibrary ( path. to_owned ( ) ) ) ?;
949948 self . state . set_file_state ( path. to_owned ( ) , true ) ;
950949 Ok ( ProcessedData :: new ( vec ! [ finalized_type_library] ) )
@@ -957,8 +956,7 @@ impl TypeLibProcessor {
957956 CoreTypeParser :: parser_by_name ( "ClangTypeParser" ) . expect ( "Failed to get clang parser" ) ;
958957 let platform_type_container = platform. type_container ( ) ;
959958
960- let header_contents =
961- std:: fs:: read_to_string ( path) . map_err ( |e| ProcessingError :: FileRead ( e) ) ?;
959+ let header_contents = std:: fs:: read_to_string ( path) . map_err ( ProcessingError :: FileRead ) ?;
962960
963961 let file_name = path
964962 . file_name ( )
@@ -982,7 +980,7 @@ impl TypeLibProcessor {
982980 & include_dirs,
983981 "" ,
984982 )
985- . map_err ( |e| ProcessingError :: TypeParsingFailed ( e ) ) ?;
983+ . map_err ( ProcessingError :: TypeParsingFailed ) ?;
986984
987985 let type_library = TypeLibrary :: new ( platform. arch ( ) , & self . default_dependency_name ) ;
988986 type_library. add_platform ( & platform) ;
@@ -1000,7 +998,7 @@ impl TypeLibProcessor {
1000998 /// most important for us is the list of exported symbols, which we can use to relocate objects
1001999 /// in the default type library (specified by `default_dependency_name`) to the correct type library.
10021000 pub fn process_tbd ( & self , path : & Path ) -> Result < ProcessedData , ProcessingError > {
1003- let mut file = File :: open ( path) . map_err ( |e| ProcessingError :: FileRead ( e ) ) ?;
1001+ let mut file = File :: open ( path) . map_err ( ProcessingError :: FileRead ) ?;
10041002 let mut type_libraries = Vec :: new ( ) ;
10051003 for tbd_info in parse_tbd_info ( & mut file) . unwrap ( ) {
10061004 let install_path = PathBuf :: from ( tbd_info. install_name ) ;
@@ -1066,7 +1064,7 @@ impl TypeLibProcessor {
10661064 }
10671065 let platform = self . default_platform ( ) ?;
10681066 let type_libraries = WindowsMetadataImporter :: new ( )
1069- . with_files ( & paths)
1067+ . with_files ( paths)
10701068 . map_err ( ProcessingError :: WinMdFailedImport ) ?
10711069 . import ( & platform)
10721070 . map_err ( ProcessingError :: WinMdFailedImport ) ?;
@@ -1090,8 +1088,8 @@ pub fn is_parsable(path: &Path) -> bool {
10901088 if path. extension ( ) == Some ( OsStr :: new ( "pdb" ) ) {
10911089 return false ;
10921090 }
1093- let mut metadata = FileMetadata :: with_file_path ( & path) ;
1094- let Ok ( view) = BinaryView :: from_path ( & mut metadata, path) else {
1091+ let mut metadata = FileMetadata :: with_file_path ( path) ;
1092+ let Ok ( view) = BinaryView :: from_path ( & metadata, path) else {
10951093 return false ;
10961094 } ;
10971095 // If any view type parses this file, consider it for this source.
0 commit comments