Skip to content

Rust: 128-bit integer literals are not parsed correctly #33

@LordHavelockVetinari

Description

@LordHavelockVetinari

The code which parses integer suffixes recognizes the suffixes: u8, i8, u16, i16, u32, i32, u64, i64, usize and isize, but not u128 and i128, so integer literals like 10u128 or 0xffffi128 are marked as errors.

lexilla/lexers/LexRust.cxx

Lines 272 to 293 in 782725a

/* Scan initial digits. The literal is malformed if there are none. */
error |= !ScanDigits(styler, pos, base);
/* See if there's an integer suffix. We mimic the Rust's lexer
* and munch it even if there was an error above. */
c = styler.SafeGetCharAt(pos, '\0');
if (c == 'u' || c == 'i') {
pos++;
c = styler.SafeGetCharAt(pos, '\0');
n = styler.SafeGetCharAt(pos + 1, '\0');
if (c == '8') {
pos++;
} else if (c == '1' && n == '6') {
pos += 2;
} else if (c == '3' && n == '2') {
pos += 2;
} else if (c == '6' && n == '4') {
pos += 2;
} else if (styler.Match(pos, "size")) {
pos += 4;
} else {
error = true;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    rustCaused by the rust lexer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions