@@ -370,15 +370,23 @@ impl RealFileName {
370370 ///
371371 /// May not exists if the filename was imported from another crate.
372372 pub fn local_path ( & self ) -> Option < & Path > {
373- self . local . as_ref ( ) . map ( |lp| lp. name . as_ref ( ) )
373+ if !self . was_remapped ( ) {
374+ Some ( & self . maybe_remapped . name )
375+ } else {
376+ self . local . as_ref ( ) . map ( |lp| lp. name . as_ref ( ) )
377+ }
374378 }
375379
376380 /// Returns the path suitable for reading from the file system on the local host,
377381 /// if this information exists.
378382 ///
379383 /// May not exists if the filename was imported from another crate.
380384 pub fn into_local_path ( self ) -> Option < PathBuf > {
381- self . local . map ( |lp| lp. name )
385+ if !self . was_remapped ( ) {
386+ Some ( self . maybe_remapped . name )
387+ } else {
388+ self . local . map ( |lp| lp. name )
389+ }
382390 }
383391
384392 /// Returns whenever the filename was remapped.
@@ -420,9 +428,14 @@ impl RealFileName {
420428 /// Update the filename for encoding in the crate metadata.
421429 ///
422430 /// Currently it's about removing the local part when the filename
423- /// is fully remapped.
431+ /// is either fully remapped or not remapped at all.
432+ #[ inline]
424433 pub fn update_for_crate_metadata ( & mut self ) {
425- if self . scopes . is_all ( ) {
434+ if self . scopes . is_all ( ) || self . scopes . is_empty ( ) {
435+ // NOTE: This works because when the filename is fully
436+ // remapped, we don't care about the `local` part,
437+ // and when the filename is not remapped at all,
438+ // `maybe_remapped` and `local` are equal.
426439 self . local = None ;
427440 }
428441 }
0 commit comments