Fix maximum bitfields range
Range is exclusive. To match the MSB 32 for `range.end` has to be
allowed.
@@ -127,7 +127,7 @@ fn parse_range(mut s: &str) -> Option<(Range<u8>, usize /* consumed */)> {
return None;
}
- if start >= 32 || end >= 32 {
+ if start >= 32 || end > 32 {
return None;
}
@@ -887,9 +887,9 @@ mod tests {
// start > end
assert!(parse("{=1..0}", ParserMode::Strict).is_err());
// out of 32-bit range
- assert!(parse("{=0..32}", ParserMode::Strict).is_err());
+ assert!(parse("{=0..33}", ParserMode::Strict).is_err());
// just inside 32-bit range
- assert!(parse("{=0..31}", ParserMode::Strict).is_ok());
+ assert!(parse("{=0..32}", ParserMode::Strict).is_ok());
// missing parts
assert!(parse("{=0..4", ParserMode::Strict).is_err());
