Skip to content

Commit ac5cf76

Browse files
committed
Prevent double encoding when the filename wasn't remapped at all
This is done by making the `local` part of `RealFileName` none. This works because `maybe_remapped` is equal to `local` when no remapping happened.
1 parent 8188f6c commit ac5cf76

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/rustc_span/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,14 @@ impl RealFileName {
420420
/// Update the filename for encoding in the crate metadata.
421421
///
422422
/// Currently it's about removing the local part when the filename
423-
/// is fully remapped.
423+
/// is either fully remapped or not remapped at all.
424+
#[inline]
424425
pub fn update_for_crate_metadata(&mut self) {
425-
if self.scopes.is_all() {
426+
if self.scopes.is_all() || self.scopes.is_empty() {
427+
// NOTE: This works because when the filename is fully
428+
// remapped, we don't care about the `local` part,
429+
// and when the filename is not remapped at all,
430+
// `maybe_remapped` and `local` are equal.
426431
self.local = None;
427432
}
428433
}

0 commit comments

Comments
 (0)