@@ -119,27 +119,28 @@ pub fn extract(
119
119
source : & [ u8 ] ,
120
120
ranges : & [ Range ] ,
121
121
) -> std:: io:: Result < ( ) > {
122
+ let path_str = format ! ( "{}" , path. display( ) ) ;
122
123
let span = span ! (
123
124
Level :: TRACE ,
124
125
"extract" ,
125
- file = %path . display ( )
126
+ file = %path_str
126
127
) ;
127
128
128
129
let _enter = span. enter ( ) ;
129
130
130
- info ! ( "extracting: {}" , path . display ( ) ) ;
131
+ info ! ( "extracting: {}" , path_str ) ;
131
132
132
133
let mut parser = Parser :: new ( ) ;
133
134
parser. set_language ( language) . unwrap ( ) ;
134
135
parser. set_included_ranges ( ranges) . unwrap ( ) ;
135
136
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 ) ) ;
137
138
let file_label = populate_file ( trap_writer, path) ;
138
139
let mut visitor = Visitor {
139
140
source,
140
141
trap_writer,
141
142
// TODO: should we handle path strings that are not valid UTF8 better?
142
- path : format ! ( "{}" , path . display ( ) ) ,
143
+ path : & path_str ,
143
144
file_label,
144
145
toplevel_child_counter : 0 ,
145
146
stack : Vec :: new ( ) ,
@@ -199,7 +200,7 @@ struct ChildNode {
199
200
200
201
struct Visitor < ' a > {
201
202
/// The file path of the source code (as string)
202
- path : String ,
203
+ path : & ' a str ,
203
204
/// The label to use whenever we need to refer to the `@file` entity of this
204
205
/// source file.
205
206
file_label : trap:: Label ,
0 commit comments