@@ -2268,6 +2268,8 @@ pub struct EncodedMetadata {
22682268 // This is an optional stub metadata containing only the crate header.
22692269 // The header should be very small, so we load it directly into memory.
22702270 stub_metadata : Option < Vec < u8 > > ,
2271+ // The path containing the metadata, to record as work product.
2272+ path : Option < Box < Path > > ,
22712273 // We need to carry MaybeTempDir to avoid deleting the temporary
22722274 // directory while accessing the Mmap.
22732275 _temp_dir : Option < MaybeTempDir > ,
@@ -2283,14 +2285,24 @@ impl EncodedMetadata {
22832285 let file = std:: fs:: File :: open ( & path) ?;
22842286 let file_metadata = file. metadata ( ) ?;
22852287 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+ } ) ;
22872294 }
22882295 let full_mmap = unsafe { Some ( Mmap :: map ( file) ?) } ;
22892296
22902297 let stub =
22912298 if let Some ( stub_path) = stub_path { Some ( std:: fs:: read ( stub_path) ?) } else { None } ;
22922299
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+ } )
22942306 }
22952307
22962308 #[ inline]
@@ -2302,6 +2314,11 @@ impl EncodedMetadata {
23022314 pub fn stub_or_full ( & self ) -> & [ u8 ] {
23032315 self . stub_metadata . as_deref ( ) . unwrap_or ( self . full ( ) )
23042316 }
2317+
2318+ #[ inline]
2319+ pub fn path ( & self ) -> Option < & Path > {
2320+ self . path . as_deref ( )
2321+ }
23052322}
23062323
23072324impl < S : Encoder > Encodable < S > for EncodedMetadata {
@@ -2326,7 +2343,7 @@ impl<D: Decoder> Decodable<D> for EncodedMetadata {
23262343 None
23272344 } ;
23282345
2329- Self { full_metadata, stub_metadata : stub, _temp_dir : None }
2346+ Self { full_metadata, stub_metadata : stub, path : None , _temp_dir : None }
23302347 }
23312348}
23322349
0 commit comments