Revert "Merge pull request #7267 from joshuawarner32/fuzzing-bugs-2"

This reverts commit 364249a29d, reversing
changes made to 0e550a7f68.
This commit is contained in:
Anton-4 2024-11-30 18:43:16 +01:00
parent a92cf2fdf9
commit 74d137cad4
No known key found for this signature in database
GPG key ID: 0971D718C0A9B937
347 changed files with 1157 additions and 8214 deletions

View file

@ -18,14 +18,12 @@ pub struct Buf<'a> {
spaces_to_flush: usize,
newlines_to_flush: usize,
beginning_of_line: bool,
line_indent: u16,
}
impl<'a> Buf<'a> {
pub fn new_in(arena: &'a Bump) -> Buf<'a> {
Buf {
text: String::new_in(arena),
line_indent: 0,
spaces_to_flush: 0,
newlines_to_flush: 0,
beginning_of_line: true,
@ -42,18 +40,11 @@ impl<'a> Buf<'a> {
pub fn indent(&mut self, indent: u16) {
if self.beginning_of_line {
self.line_indent = indent;
self.spaces_to_flush = indent as usize;
}
self.beginning_of_line = false;
}
pub fn cur_line_indent(&self) -> u16 {
debug_assert!(!self.beginning_of_line, "cur_line_indent before indent");
self.line_indent
}
#[track_caller]
pub fn push(&mut self, ch: char) {
debug_assert!(!self.beginning_of_line);
debug_assert!(
@ -70,7 +61,6 @@ impl<'a> Buf<'a> {
self.text.push(ch);
}
#[track_caller]
pub fn push_str_allow_spaces(&mut self, s: &str) {
debug_assert!(
!self.beginning_of_line,
@ -83,7 +73,6 @@ impl<'a> Buf<'a> {
self.text.push_str(s);
}
#[track_caller]
pub fn push_str(&mut self, s: &str) {
debug_assert!(
!self.beginning_of_line,
@ -140,12 +129,6 @@ impl<'a> Buf<'a> {
}
}
pub fn ensure_ends_with_whitespace(&mut self) {
if !self.text.is_empty() && self.newlines_to_flush == 0 && self.spaces_to_flush == 0 {
self.spaces_to_flush = 1;
}
}
fn flush_spaces(&mut self) {
for _ in 0..self.newlines_to_flush {
self.text.push('\n');