Skip to content

Commit 07e12db

Browse files
Got rustc_metadata compiling.
1 parent 876dc71 commit 07e12db

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/librustc_metadata/rmeta/decoder.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16351635
// containing the information we need.
16361636
let rustc_span::SourceFile {
16371637
mut name,
1638-
name_was_remapped,
16391638
src_hash,
16401639
start_pos,
16411640
end_pos,
@@ -1652,7 +1651,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16521651
// on `try_to_translate_virtual_to_real`).
16531652
// FIXME(eddyb) we could check `name_was_remapped` here,
16541653
// but in practice it seems to be always `false`.
1655-
try_to_translate_virtual_to_real(&mut name);
1654+
try_to_translate_virtual_to_real(name.name_mut());
16561655

16571656
let source_length = (end_pos - start_pos).to_usize();
16581657

@@ -1675,8 +1674,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16751674
}
16761675

16771676
let local_version = sess.source_map().new_imported_source_file(
1678-
name,
1679-
name_was_remapped,
1677+
name.name().clone(),
1678+
name.was_remapped(),
16801679
src_hash,
16811680
name_hash,
16821681
source_length,

src/librustc_metadata/rmeta/encoder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
445445
(!source_file.is_imported() || self.is_proc_macro)
446446
})
447447
.map(|(_, source_file)| {
448-
let mut adapted = match source_file.name {
448+
let mut adapted = match source_file.name.name() {
449449
// This path of this SourceFile has been modified by
450450
// path-remapping, so we use it verbatim (and avoid
451451
// cloning the whole map in the process).
452-
_ if source_file.name_was_remapped => source_file.clone(),
452+
_ if source_file.name.was_remapped() => source_file.clone(),
453453

454454
// Otherwise expand all paths to absolute paths because
455455
// any relative paths are potentially relative to a
@@ -460,7 +460,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
460460
adapted.name = Path::new(&working_dir).join(name).into();
461461
adapted.name_hash = {
462462
let mut hasher: StableHasher = StableHasher::new();
463-
adapted.name.hash(&mut hasher);
463+
adapted.name.name().hash(&mut hasher);
464464
hasher.finish::<u128>()
465465
};
466466
Lrc::new(adapted)

src/librustc_span/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,10 @@ impl SourceFileName {
10961096
&self.name
10971097
}
10981098

1099+
pub fn name_mut(&mut self) -> &mut FileName {
1100+
&mut self.name
1101+
}
1102+
10991103
pub fn unmapped_path(&self) -> &FileName {
11001104
self.unmapped_name.as_ref().unwrap_or(self.name())
11011105
}
@@ -1109,6 +1113,14 @@ impl SourceFileName {
11091113
}
11101114
}
11111115

1116+
/// This conversion assumes that the path was not remapped (ie name == unmapped_name)
1117+
impl From<PathBuf> for SourceFileName {
1118+
fn from(path: PathBuf) -> Self {
1119+
let name: FileName = path.into();
1120+
Self::new(name.clone(), false, Some(name))
1121+
}
1122+
}
1123+
11121124
impl Encodable for SourceFileName {
11131125
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
11141126
s.emit_struct("SourceFileName", 3, |s| {

0 commit comments

Comments
 (0)