@@ -172,7 +172,7 @@ impl<S: Encoder> Encodable<S> for RealFileName {
172172impl RealFileName {
173173 /// Returns the path suitable for reading from the file system on the local host,
174174 /// if this information exists.
175- /// Avoid embedding this in build artifacts; see `stable_name ()` for that.
175+ /// Avoid embedding this in build artifacts; see `remapped_path_if_available ()` for that.
176176 pub fn local_path ( & self ) -> Option < & Path > {
177177 match self {
178178 RealFileName :: LocalPath ( p) => Some ( p) ,
@@ -184,39 +184,41 @@ impl RealFileName {
184184
185185 /// Returns the path suitable for reading from the file system on the local host,
186186 /// if this information exists.
187- /// Avoid embedding this in build artifacts; see `stable_name ()` for that.
187+ /// Avoid embedding this in build artifacts; see `remapped_path_if_available ()` for that.
188188 pub fn into_local_path ( self ) -> Option < PathBuf > {
189189 match self {
190190 RealFileName :: LocalPath ( p) => Some ( p) ,
191191 RealFileName :: Remapped { local_path : p, virtual_name : _ } => p,
192192 }
193193 }
194194
195- /// Returns the path suitable for embedding into build artifacts. Note that
196- /// a remapped path will not correspond to a valid file system path; see
197- /// `local_path()` for something that is more likely to return paths into the
198- /// local host file system.
199- pub fn stable_name ( & self ) -> & Path {
195+ /// Returns the path suitable for embedding into build artifacts. This would still
196+ /// be a local path if it has not been remapped. A remapped path will not correspond
197+ /// to a valid file system path: see `local_path_if_available()` for something that
198+ /// is more likely to return paths into the local host file system.
199+ pub fn remapped_path_if_available ( & self ) -> & Path {
200200 match self {
201201 RealFileName :: LocalPath ( p)
202202 | RealFileName :: Remapped { local_path : _, virtual_name : p } => & p,
203203 }
204204 }
205205
206- fn to_string_lossy ( & self , prefer_local : bool ) -> Cow < ' _ , str > {
207- use RealFileName :: * ;
206+ /// Returns the path suitable for reading from the file system on the local host,
207+ /// if this information exists. Otherwise returns the remapped name.
208+ /// Avoid embedding this in build artifacts; see `remapped_path_if_available()` for that.
209+ pub fn local_path_if_available ( & self ) -> & Path {
210+ match self {
211+ RealFileName :: LocalPath ( path)
212+ | RealFileName :: Remapped { local_path : None , virtual_name : path }
213+ | RealFileName :: Remapped { local_path : Some ( path) , virtual_name : _ } => path,
214+ }
215+ }
216+
217+ pub fn to_string_lossy ( & self , prefer_local : bool ) -> Cow < ' _ , str > {
208218 if prefer_local {
209- match self {
210- LocalPath ( path)
211- | Remapped { local_path : None , virtual_name : path }
212- | Remapped { local_path : Some ( path) , virtual_name : _ } => path. to_string_lossy ( ) ,
213- }
219+ self . local_path_if_available ( ) . to_string_lossy ( )
214220 } else {
215- match self {
216- LocalPath ( path) | Remapped { local_path : _, virtual_name : path } => {
217- path. to_string_lossy ( )
218- }
219- }
221+ self . remapped_path_if_available ( ) . to_string_lossy ( )
220222 }
221223 }
222224}
@@ -1358,7 +1360,7 @@ impl<D: Decoder> Decodable<D> for SourceFile {
13581360
13591361impl fmt:: Debug for SourceFile {
13601362 fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1361- write ! ( fmt, "SourceFile({})" , self . name)
1363+ write ! ( fmt, "SourceFile({:? })" , self . name)
13621364 }
13631365}
13641366
0 commit comments