Skip to content

Commit 69d364b

Browse files
authoredOct 29, 2016
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.)
2 parents 75a87c5 + 3f639a0 commit 69d364b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
 

‎src/librustc_metadata/decoder.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,14 @@ impl<'a, 'tcx> CrateMetadata {
11381138

11391139
match reusable_filemap {
11401140
Some(fm) => {
1141+
1142+
debug!("CrateMetaData::imported_filemaps reuse \
1143+
filemap {:?} original (start_pos {:?} end_pos {:?}) \
1144+
translated (start_pos {:?} end_pos {:?})",
1145+
filemap_to_import.name,
1146+
filemap_to_import.start_pos, filemap_to_import.end_pos,
1147+
fm.start_pos, fm.end_pos);
1148+
11411149
cstore::ImportedFileMap {
11421150
original_start_pos: filemap_to_import.start_pos,
11431151
original_end_pos: filemap_to_import.end_pos,
@@ -1176,6 +1184,12 @@ impl<'a, 'tcx> CrateMetadata {
11761184
source_length,
11771185
lines,
11781186
multibyte_chars);
1187+
debug!("CrateMetaData::imported_filemaps alloc \
1188+
filemap {:?} original (start_pos {:?} end_pos {:?}) \
1189+
translated (start_pos {:?} end_pos {:?})",
1190+
local_version.name, start_pos, end_pos,
1191+
local_version.start_pos, local_version.end_pos);
1192+
11791193
cstore::ImportedFileMap {
11801194
original_start_pos: start_pos,
11811195
original_end_pos: end_pos,
@@ -1193,6 +1207,10 @@ impl<'a, 'tcx> CrateMetadata {
11931207
}
11941208

11951209
fn are_equal_modulo_startpos(fm1: &syntax_pos::FileMap, fm2: &syntax_pos::FileMap) -> bool {
1210+
if fm1.byte_length() != fm2.byte_length() {
1211+
return false;
1212+
}
1213+
11961214
if fm1.name != fm2.name {
11971215
return false;
11981216
}

‎src/libsyntax_pos/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ impl FileMap {
481481
self.src.is_none()
482482
}
483483

484+
pub fn byte_length(&self) -> u32 {
485+
self.end_pos.0 - self.start_pos.0
486+
}
484487
pub fn count_lines(&self) -> usize {
485488
self.lines.borrow().len()
486489
}

0 commit comments

Comments
 (0)