File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
c2rust-transpile/src/translator Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -518,7 +518,11 @@ pub fn translate(
518518
519519 // Compute source ranges of top decls before pruning any, because pruned
520520 // decls may help inform the ranges of kept ones.
521- let decl_source_ranges = t. ast_context . top_decl_locs ( ) ;
521+ let decl_source_ranges = if tcfg. emit_c_decl_map {
522+ Some ( t. ast_context . top_decl_locs ( ) )
523+ } else {
524+ None
525+ } ;
522526
523527 // Headers often pull in declarations that are unused;
524528 // we simplify the translator output by omitting those.
@@ -770,7 +774,7 @@ pub fn translate(
770774 . collect :: < HashMap < _ , _ > > ( ) ;
771775
772776 // Generate a map from Rust items to the source code of their C declarations.
773- let decl_map = if tcfg . emit_c_decl_map {
777+ let decl_map = if let Some ( decl_source_ranges ) = decl_source_ranges {
774778 let mut path_to_c_source_range: HashMap < & Ident , ( SrcLoc , SrcLoc ) > = Default :: default ( ) ;
775779 for ( decl, source_range) in decl_source_ranges {
776780 match converted_decls. get ( & decl) {
You can’t perform that action at this time.
0 commit comments