Skip to content

Commit ba30c1d

Browse files
syntax_pos: Store multibyte char size as u8 instead of u32.
1 parent ba1d18f commit ba30c1d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/libsyntax/codemap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -819,10 +819,10 @@ impl CodeMap {
819819
if mbc.pos < bpos {
820820
// every character is at least one byte, so we only
821821
// count the actual extra bytes.
822-
total_extra_bytes += mbc.bytes - 1;
822+
total_extra_bytes += mbc.bytes as u32 - 1;
823823
// We should never see a byte position in the middle of a
824824
// character
825-
assert!(bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes);
825+
assert!(bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32);
826826
} else {
827827
break;
828828
}

src/libsyntax_pos/analyze_filemap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ fn analyze_filemap_generic(src: &str,
263263
assert!(char_len >=2 && char_len <= 4);
264264
let mbc = MultiByteChar {
265265
pos,
266-
bytes: char_len as u32,
266+
bytes: char_len as u8,
267267
};
268268
multi_byte_chars.push(mbc);
269269
}

src/libsyntax_pos/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ pub struct MultiByteChar {
663663
/// The absolute offset of the character in the CodeMap
664664
pub pos: BytePos,
665665
/// The number of bytes, >=2
666-
pub bytes: u32,
666+
pub bytes: u8,
667667
}
668668

669669
/// Identifies an offset of a non-narrow character in a FileMap

0 commit comments

Comments
 (0)