Auto merge of #37449 - pnkfelix:fix-issue-37274, r=eddyb

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.)
This commit is contained in:
bors 2016-10-29 08:54:30 -07:00 committed by GitHub
commit 69d364bc4f
2 changed files with 21 additions and 0 deletions

View file

@ -1138,6 +1138,14 @@ pub fn imported_filemaps(&'a self,
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,
@ -1176,6 +1184,12 @@ pub fn imported_filemaps(&'a self,
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,
@ -1193,6 +1207,10 @@ pub fn imported_filemaps(&'a self,
}
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;
}

View file

@ -481,6 +481,9 @@ pub fn is_imported(&self) -> bool {
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()
}