Skip to content

Commit 075f4cd

Browse files
committed
Restore embedding warning and simply {,into_}local_path methods
1 parent c877536 commit 075f4cd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

compiler/rustc_span/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,25 +374,33 @@ impl RealFileName {
374374
/// if this information exists.
375375
///
376376
/// May not exists if the filename was imported from another crate.
377+
///
378+
/// Avoid embedding this in build artifacts; prefer `path()` or `embeddable_name()`.
377379
#[inline]
378380
pub fn local_path(&self) -> Option<&Path> {
379381
if self.was_not_remapped() {
380382
Some(&self.maybe_remapped.name)
383+
} else if let Some(local) = &self.local {
384+
Some(&local.name)
381385
} else {
382-
self.local.as_ref().map(|lp| lp.name.as_ref())
386+
None
383387
}
384388
}
385389

386390
/// Returns the path suitable for reading from the file system on the local host,
387391
/// if this information exists.
388392
///
389393
/// May not exists if the filename was imported from another crate.
394+
///
395+
/// Avoid embedding this in build artifacts; prefer `path()` or `embeddable_name()`.
390396
#[inline]
391397
pub fn into_local_path(self) -> Option<PathBuf> {
392398
if self.was_not_remapped() {
393399
Some(self.maybe_remapped.name)
400+
} else if let Some(local) = self.local {
401+
Some(local.name)
394402
} else {
395-
self.local.map(|lp| lp.name)
403+
None
396404
}
397405
}
398406

0 commit comments

Comments
 (0)