@@ -21,7 +21,7 @@ use quote::ToTokens;
2121use std:: { io:: Read , path:: PathBuf } ;
2222use std:: { panic:: UnwindSafe , path:: Path , rc:: Rc } ;
2323use syn:: spanned:: Spanned ;
24- use syn:: { token :: Brace , Item , ItemMod } ;
24+ use syn:: Item ;
2525use thiserror:: Error ;
2626
2727/// Errors which may occur when parsing a Rust source file to discover
@@ -119,7 +119,7 @@ fn parse_file_contents(
119119 Segment :: Cxx ( CxxBridge :: from ( itm) )
120120 }
121121 Item :: Mod ( itm) => {
122- if let Some ( ( brace , items) ) = itm. content {
122+ if let Some ( ( _ , items) ) = itm. content {
123123 let mut mod_state = State {
124124 auto_allowlist : self . auto_allowlist ,
125125 ..Default :: default ( )
@@ -137,18 +137,9 @@ fn parse_file_contents(
137137 }
138138 self . extra_superclasses . extend ( mod_state. extra_superclasses ) ;
139139 self . discoveries . extend ( mod_state. discoveries ) ;
140- Segment :: Mod (
141- mod_state. results ,
142- (
143- brace,
144- ItemMod {
145- content : None ,
146- ..itm
147- } ,
148- ) ,
149- )
140+ Segment :: Mod ( mod_state. results )
150141 } else {
151- Segment :: Other ( Item :: Mod ( itm ) )
142+ Segment :: Other
152143 }
153144 }
154145 Item :: Struct ( ref its) => {
@@ -189,13 +180,13 @@ fn parse_file_contents(
189180 self . discoveries
190181 . search_item ( & item, mod_path)
191182 . map_err ( ParseError :: Discovery ) ?;
192- Segment :: Other ( item )
183+ Segment :: Other
193184 }
194185 _ => {
195186 self . discoveries
196187 . search_item ( & item, mod_path)
197188 . map_err ( ParseError :: Discovery ) ?;
198- Segment :: Other ( item )
189+ Segment :: Other
199190 }
200191 } ;
201192 self . results . push ( result) ;
@@ -283,8 +274,8 @@ pub struct ParsedFile(Vec<Segment>);
283274enum Segment {
284275 Autocxx ( IncludeCppEngine ) ,
285276 Cxx ( CxxBridge ) ,
286- Mod ( Vec < Segment > , ( Brace , ItemMod ) ) ,
287- Other ( Item ) ,
277+ Mod ( Vec < Segment > ) ,
278+ Other ,
288279}
289280
290281pub trait CppBuildable {
@@ -303,7 +294,7 @@ impl ParsedFile {
303294 . flat_map ( |s| -> Box < dyn Iterator < Item = & IncludeCppEngine > > {
304295 match s {
305296 Segment :: Autocxx ( includecpp) => Box :: new ( std:: iter:: once ( includecpp) ) ,
306- Segment :: Mod ( segments, _ ) => Box :: new ( do_get_autocxxes ( segments) ) ,
297+ Segment :: Mod ( segments) => Box :: new ( do_get_autocxxes ( segments) ) ,
307298 _ => Box :: new ( std:: iter:: empty ( ) ) ,
308299 }
309300 } )
@@ -331,7 +322,7 @@ impl ParsedFile {
331322 Segment :: Cxx ( cxxbridge) => {
332323 Box :: new ( std:: iter:: once ( cxxbridge as & dyn CppBuildable ) )
333324 }
334- Segment :: Mod ( segments, _ ) => Box :: new ( do_get_cpp_buildables ( segments) ) ,
325+ Segment :: Mod ( segments) => Box :: new ( do_get_cpp_buildables ( segments) ) ,
335326 _ => Box :: new ( std:: iter:: empty ( ) ) ,
336327 }
337328 } )
@@ -349,7 +340,7 @@ impl ParsedFile {
349340 . flat_map ( |s| -> Box < dyn Iterator < Item = & mut IncludeCppEngine > > {
350341 match s {
351342 Segment :: Autocxx ( includecpp) => Box :: new ( std:: iter:: once ( includecpp) ) ,
352- Segment :: Mod ( segments, _ ) => Box :: new ( do_get_autocxxes_mut ( segments) ) ,
343+ Segment :: Mod ( segments) => Box :: new ( do_get_autocxxes_mut ( segments) ) ,
353344 _ => Box :: new ( std:: iter:: empty ( ) ) ,
354345 }
355346 } )
@@ -368,7 +359,7 @@ impl ParsedFile {
368359 . flat_map ( |s| -> Box < dyn Iterator < Item = & PathBuf > > {
369360 match s {
370361 Segment :: Autocxx ( includecpp) => Box :: new ( includecpp. include_dirs ( ) ) ,
371- Segment :: Mod ( segments, _ ) => Box :: new ( do_get_include_dirs ( segments) ) ,
362+ Segment :: Mod ( segments) => Box :: new ( do_get_include_dirs ( segments) ) ,
372363 _ => Box :: new ( std:: iter:: empty ( ) ) ,
373364 }
374365 } )
0 commit comments