@@ -2307,6 +2307,8 @@ pub struct EncodedMetadata {
2307
2307
// This is an optional stub metadata containing only the crate header.
2308
2308
// The header should be very small, so we load it directly into memory.
2309
2309
stub_metadata : Option < Vec < u8 > > ,
2310
+ // The path containing the metadata, to record as work product.
2311
+ path : Option < Box < Path > > ,
2310
2312
// We need to carry MaybeTempDir to avoid deleting the temporary
2311
2313
// directory while accessing the Mmap.
2312
2314
_temp_dir : Option < MaybeTempDir > ,
@@ -2322,14 +2324,24 @@ impl EncodedMetadata {
2322
2324
let file = std:: fs:: File :: open ( & path) ?;
2323
2325
let file_metadata = file. metadata ( ) ?;
2324
2326
if file_metadata. len ( ) == 0 {
2325
- return Ok ( Self { full_metadata : None , stub_metadata : None , _temp_dir : None } ) ;
2327
+ return Ok ( Self {
2328
+ full_metadata : None ,
2329
+ stub_metadata : None ,
2330
+ path : None ,
2331
+ _temp_dir : None ,
2332
+ } ) ;
2326
2333
}
2327
2334
let full_mmap = unsafe { Some ( Mmap :: map ( file) ?) } ;
2328
2335
2329
2336
let stub =
2330
2337
if let Some ( stub_path) = stub_path { Some ( std:: fs:: read ( stub_path) ?) } else { None } ;
2331
2338
2332
- Ok ( Self { full_metadata : full_mmap, stub_metadata : stub, _temp_dir : temp_dir } )
2339
+ Ok ( Self {
2340
+ full_metadata : full_mmap,
2341
+ stub_metadata : stub,
2342
+ path : Some ( path. into ( ) ) ,
2343
+ _temp_dir : temp_dir,
2344
+ } )
2333
2345
}
2334
2346
2335
2347
#[ inline]
@@ -2341,6 +2353,11 @@ impl EncodedMetadata {
2341
2353
pub fn stub_or_full ( & self ) -> & [ u8 ] {
2342
2354
self . stub_metadata . as_deref ( ) . unwrap_or ( self . full ( ) )
2343
2355
}
2356
+
2357
+ #[ inline]
2358
+ pub fn path ( & self ) -> Option < & Path > {
2359
+ self . path . as_deref ( )
2360
+ }
2344
2361
}
2345
2362
2346
2363
impl < S : Encoder > Encodable < S > for EncodedMetadata {
@@ -2365,7 +2382,7 @@ impl<D: Decoder> Decodable<D> for EncodedMetadata {
2365
2382
None
2366
2383
} ;
2367
2384
2368
- Self { full_metadata, stub_metadata : stub, _temp_dir : None }
2385
+ Self { full_metadata, stub_metadata : stub, path : None , _temp_dir : None }
2369
2386
}
2370
2387
}
2371
2388
0 commit comments