Underscores must sit between digits: no leading, trailing, or consecutive. Empty body only valid after a decimal dot. */
(&mut self, start: usize, end: usize, allow_empty: bool)
| 67 | |
| 68 | /* Underscores must sit between digits: no leading, trailing, or consecutive. Empty body only valid after a decimal dot. */ |
| 69 | fn check_digits(&mut self, start: usize, end: usize, allow_empty: bool) { |
| 70 | if start == end { |
| 71 | if !allow_empty { |
| 72 | self.report(start, end, "missing digits in numeric literal"); |
| 73 | } |
| 74 | return; |
| 75 | } |
| 76 | let s = &self.src[start..end]; |
| 77 | if s[0] == b'_' || s[s.len() - 1] == b'_' { |
| 78 | self.report(start, end, "invalid '_' in numeric literal"); |
| 79 | } else if s.windows(2).any(|w| w == [b'_', b'_']) { |
| 80 | self.report(start, end, "consecutive '_' in numeric literal"); |
| 81 | } |
| 82 | } |
| 83 | fn scan_hex_digits(&mut self) { |
| 84 | self.scan_while(|b| b.is_ascii_hexdigit() || b == b'_'); |
| 85 | } |
no test coverage detected