@@ -2307,6 +2307,8 @@ pub struct EncodedMetadata {
23072307 // This is an optional stub metadata containing only the crate header.
23082308 // The header should be very small, so we load it directly into memory.
23092309 stub_metadata : Option < Vec < u8 > > ,
2310+ // The path containing the metadata, to record as work product.
2311+ path : Option < Box < Path > > ,
23102312 // We need to carry MaybeTempDir to avoid deleting the temporary
23112313 // directory while accessing the Mmap.
23122314 _temp_dir : Option < MaybeTempDir > ,
@@ -2322,14 +2324,24 @@ impl EncodedMetadata {
23222324 let file = std:: fs:: File :: open ( & path) ?;
23232325 let file_metadata = file. metadata ( ) ?;
23242326 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+ } ) ;
23262333 }
23272334 let full_mmap = unsafe { Some ( Mmap :: map ( file) ?) } ;
23282335
23292336 let stub =
23302337 if let Some ( stub_path) = stub_path { Some ( std:: fs:: read ( stub_path) ?) } else { None } ;
23312338
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+ } )
23332345 }
23342346
23352347 #[ inline]
@@ -2341,6 +2353,11 @@ impl EncodedMetadata {
23412353 pub fn stub_or_full ( & self ) -> & [ u8 ] {
23422354 self . stub_metadata . as_deref ( ) . unwrap_or ( self . full ( ) )
23432355 }
2356+
2357+ #[ inline]
2358+ pub fn path ( & self ) -> Option < & Path > {
2359+ self . path . as_deref ( )
2360+ }
23442361}
23452362
23462363impl < S : Encoder > Encodable < S > for EncodedMetadata {
@@ -2365,7 +2382,7 @@ impl<D: Decoder> Decodable<D> for EncodedMetadata {
23652382 None
23662383 } ;
23672384
2368- Self { full_metadata, stub_metadata : stub, _temp_dir : None }
2385+ Self { full_metadata, stub_metadata : stub, path : None , _temp_dir : None }
23692386 }
23702387}
23712388
0 commit comments