@@ -119,27 +119,28 @@ pub fn extract(
119119 source : & [ u8 ] ,
120120 ranges : & [ Range ] ,
121121) -> std:: io:: Result < ( ) > {
122+ let path_str = format ! ( "{}" , path. display( ) ) ;
122123 let span = span ! (
123124 Level :: TRACE ,
124125 "extract" ,
125- file = %path . display ( )
126+ file = %path_str
126127 ) ;
127128
128129 let _enter = span. enter ( ) ;
129130
130- info ! ( "extracting: {}" , path . display ( ) ) ;
131+ info ! ( "extracting: {}" , path_str ) ;
131132
132133 let mut parser = Parser :: new ( ) ;
133134 parser. set_language ( language) . unwrap ( ) ;
134135 parser. set_included_ranges ( ranges) . unwrap ( ) ;
135136 let tree = parser. parse ( & source, None ) . expect ( "Failed to parse file" ) ;
136- trap_writer. comment ( format ! ( "Auto-generated TRAP file for {}" , path . display ( ) ) ) ;
137+ trap_writer. comment ( format ! ( "Auto-generated TRAP file for {}" , path_str ) ) ;
137138 let file_label = populate_file ( trap_writer, path) ;
138139 let mut visitor = Visitor {
139140 source,
140141 trap_writer,
141142 // TODO: should we handle path strings that are not valid UTF8 better?
142- path : format ! ( "{}" , path . display ( ) ) ,
143+ path : & path_str ,
143144 file_label,
144145 toplevel_child_counter : 0 ,
145146 stack : Vec :: new ( ) ,
@@ -199,7 +200,7 @@ struct ChildNode {
199200
200201struct Visitor < ' a > {
201202 /// The file path of the source code (as string)
202- path : String ,
203+ path : & ' a str ,
203204 /// The label to use whenever we need to refer to the `@file` entity of this
204205 /// source file.
205206 file_label : trap:: Label ,
0 commit comments