@@ -2268,6 +2268,8 @@ pub struct EncodedMetadata {
2268
2268
// This is an optional stub metadata containing only the crate header.
2269
2269
// The header should be very small, so we load it directly into memory.
2270
2270
stub_metadata : Option < Vec < u8 > > ,
2271
+ // The path containing the metadata, to record as work product.
2272
+ path : Option < Box < Path > > ,
2271
2273
// We need to carry MaybeTempDir to avoid deleting the temporary
2272
2274
// directory while accessing the Mmap.
2273
2275
_temp_dir : Option < MaybeTempDir > ,
@@ -2283,14 +2285,24 @@ impl EncodedMetadata {
2283
2285
let file = std:: fs:: File :: open ( & path) ?;
2284
2286
let file_metadata = file. metadata ( ) ?;
2285
2287
if file_metadata. len ( ) == 0 {
2286
- return Ok ( Self { full_metadata : None , stub_metadata : None , _temp_dir : None } ) ;
2288
+ return Ok ( Self {
2289
+ full_metadata : None ,
2290
+ stub_metadata : None ,
2291
+ path : None ,
2292
+ _temp_dir : None ,
2293
+ } ) ;
2287
2294
}
2288
2295
let full_mmap = unsafe { Some ( Mmap :: map ( file) ?) } ;
2289
2296
2290
2297
let stub =
2291
2298
if let Some ( stub_path) = stub_path { Some ( std:: fs:: read ( stub_path) ?) } else { None } ;
2292
2299
2293
- Ok ( Self { full_metadata : full_mmap, stub_metadata : stub, _temp_dir : temp_dir } )
2300
+ Ok ( Self {
2301
+ full_metadata : full_mmap,
2302
+ stub_metadata : stub,
2303
+ path : Some ( path. into ( ) ) ,
2304
+ _temp_dir : temp_dir,
2305
+ } )
2294
2306
}
2295
2307
2296
2308
#[ inline]
@@ -2302,6 +2314,11 @@ impl EncodedMetadata {
2302
2314
pub fn stub_or_full ( & self ) -> & [ u8 ] {
2303
2315
self . stub_metadata . as_deref ( ) . unwrap_or ( self . full ( ) )
2304
2316
}
2317
+
2318
+ #[ inline]
2319
+ pub fn path ( & self ) -> Option < & Path > {
2320
+ self . path . as_deref ( )
2321
+ }
2305
2322
}
2306
2323
2307
2324
impl < S : Encoder > Encodable < S > for EncodedMetadata {
@@ -2326,7 +2343,7 @@ impl<D: Decoder> Decodable<D> for EncodedMetadata {
2326
2343
None
2327
2344
} ;
2328
2345
2329
- Self { full_metadata, stub_metadata : stub, _temp_dir : None }
2346
+ Self { full_metadata, stub_metadata : stub, path : None , _temp_dir : None }
2330
2347
}
2331
2348
}
2332
2349
0 commit comments