Skip to content

Commit

Permalink
Auto merge of #37449 - pnkfelix:fix-issue-37274, r=eddyb
Browse files Browse the repository at this point in the history
Do not intern filemap to entry w/ mismatched length.

Do not intern filemap to entry w/ mismatched length.

Fix #37274 (I think).

Beta-nominated; note that only the second commit needs to be cherry picked to beta branch. (The first just adds some debug instrumentation that I wish had been present.)
  • Loading branch information
bors committed Oct 29, 2016
2 parents 75a87c5 + 3f639a0 commit 69d364b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,14 @@ impl<'a, 'tcx> CrateMetadata {

match reusable_filemap {
Some(fm) => {

debug!("CrateMetaData::imported_filemaps reuse \
filemap {:?} original (start_pos {:?} end_pos {:?}) \
translated (start_pos {:?} end_pos {:?})",
filemap_to_import.name,
filemap_to_import.start_pos, filemap_to_import.end_pos,
fm.start_pos, fm.end_pos);

cstore::ImportedFileMap {
original_start_pos: filemap_to_import.start_pos,
original_end_pos: filemap_to_import.end_pos,
Expand Down Expand Up @@ -1176,6 +1184,12 @@ impl<'a, 'tcx> CrateMetadata {
source_length,
lines,
multibyte_chars);
debug!("CrateMetaData::imported_filemaps alloc \
filemap {:?} original (start_pos {:?} end_pos {:?}) \
translated (start_pos {:?} end_pos {:?})",
local_version.name, start_pos, end_pos,
local_version.start_pos, local_version.end_pos);

cstore::ImportedFileMap {
original_start_pos: start_pos,
original_end_pos: end_pos,
Expand All @@ -1193,6 +1207,10 @@ impl<'a, 'tcx> CrateMetadata {
}

fn are_equal_modulo_startpos(fm1: &syntax_pos::FileMap, fm2: &syntax_pos::FileMap) -> bool {
if fm1.byte_length() != fm2.byte_length() {
return false;
}

if fm1.name != fm2.name {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/libsyntax_pos/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,9 @@ impl FileMap {
self.src.is_none()
}

pub fn byte_length(&self) -> u32 {
self.end_pos.0 - self.start_pos.0
}
pub fn count_lines(&self) -> usize {
self.lines.borrow().len()
}
Expand Down

0 comments on commit 69d364b

Please sign in to comment.