From 075f4cd57f3c2b175510c25638fc23bc87d7633b Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 14 Dec 2025 13:44:14 +0100 Subject: [PATCH] Restore embedding warning and simply `{,into_}local_path` methods --- compiler/rustc_span/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 630656f9ec5c..3d641905d325 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -374,12 +374,16 @@ impl RealFileName { /// if this information exists. /// /// May not exists if the filename was imported from another crate. + /// + /// Avoid embedding this in build artifacts; prefer `path()` or `embeddable_name()`. #[inline] pub fn local_path(&self) -> Option<&Path> { if self.was_not_remapped() { Some(&self.maybe_remapped.name) + } else if let Some(local) = &self.local { + Some(&local.name) } else { - self.local.as_ref().map(|lp| lp.name.as_ref()) + None } } @@ -387,12 +391,16 @@ impl RealFileName { /// if this information exists. /// /// May not exists if the filename was imported from another crate. + /// + /// Avoid embedding this in build artifacts; prefer `path()` or `embeddable_name()`. #[inline] pub fn into_local_path(self) -> Option { if self.was_not_remapped() { Some(self.maybe_remapped.name) + } else if let Some(local) = self.local { + Some(local.name) } else { - self.local.map(|lp| lp.name) + None } }