Skip to content

Commit

Permalink
no trailing semicolons
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Nov 23, 2023
1 parent 7bba69c commit 3018443
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions crates/fmt/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ impl<'a, W: Write> Formatter<'a, W> {
/// Does the next written character require whitespace before
fn next_char_needs_space(&self, next_char: char) -> bool {
if self.is_beginning_of_line() {
return false;
return false
}
let last_char =
if let Some(last_char) = self.last_char() { last_char } else { return false };
if last_char.is_whitespace() || next_char.is_whitespace() {
return false;
return false
}
match last_char {
'{' => match next_char {
Expand All @@ -231,10 +231,10 @@ impl<'a, W: Write> Formatter<'a, W> {
fn will_it_fit(&self, text: impl AsRef<str>) -> bool {
let text = text.as_ref();
if text.is_empty() {
return true;
return true
}
if text.contains('\n') {
return false;
return false
}
let space: usize = self.next_char_needs_space(text.chars().next().unwrap()).into();
self.config.line_length >=
Expand Down Expand Up @@ -446,7 +446,7 @@ impl<'a, W: Write> Formatter<'a, W> {
/// or if the comment are wrapped
fn write_comment(&mut self, comment: &CommentWithMetadata, is_first: bool) -> Result<()> {
if self.inline_config.is_disabled(comment.loc) {
return self.write_raw_comment(comment);
return self.write_raw_comment(comment)
}

match comment.position {
Expand Down Expand Up @@ -474,7 +474,7 @@ impl<'a, W: Write> Formatter<'a, W> {
lines.try_for_each(|l| self.write_doc_block_line(comment, l))?;
write!(self.buf(), " {}", comment.end_token().unwrap())?;
self.write_preserved_line()?;
return Ok(());
return Ok(())
}

write!(self.buf(), "{}", comment.start_token())?;
Expand Down Expand Up @@ -549,7 +549,7 @@ impl<'a, W: Write> Formatter<'a, W> {
write!(self.buf(), " *{}", if needs_space { " " } else { "" })?;
self.write_comment_line(comment, line)?;
self.write_whitespace_separator(true)?;
return Ok(());
return Ok(())
}

let indent_whitespace_count = line
Expand All @@ -571,7 +571,7 @@ impl<'a, W: Write> Formatter<'a, W> {
line.chars().next().map(|ch| ch.is_whitespace()).unwrap_or_default();
if !self.is_beginning_of_line() || !start_with_ws {
write!(self.buf(), "{line}")?;
return Ok(false);
return Ok(false)
}

// if this is the beginning of the line,
Expand All @@ -583,7 +583,7 @@ impl<'a, W: Write> Formatter<'a, W> {
.map(|(_, ch)| ch);
let padded = format!("{}{}", " ".repeat(indent), chars.join(""));
self.write_raw(padded)?;
return Ok(false);
return Ok(false)
}

let mut words = line.split(' ').peekable();
Expand All @@ -602,7 +602,7 @@ impl<'a, W: Write> Formatter<'a, W> {
// write newline wrap token
write!(self.buf(), "{}", comment.wrap_token())?;
self.write_comment_line(comment, &words.join(" "))?;
return Ok(true);
return Ok(true)
}

self.write_whitespace_separator(false)?;
Expand Down Expand Up @@ -2306,7 +2306,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
#[instrument(name = "ident_path", skip_all)]
fn visit_ident_path(&mut self, idents: &mut IdentifierPath) -> Result<(), Self::Error> {
if idents.identifiers.is_empty() {
return Ok(());
return Ok(())
}
return_source_if_disabled!(self, idents.loc);

Expand Down Expand Up @@ -2476,7 +2476,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
name.content.push_str("()");
}
self.write_chunk(&name)?;
return Ok(());
return Ok(())
}

let args = base.args.as_mut().unwrap();
Expand Down Expand Up @@ -2530,7 +2530,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
write_chunk!(fmt, struct_name.loc.start(), "struct")?;
struct_name.visit(fmt)?;
if structure.fields.is_empty() {
return fmt.write_empty_brackets();
return fmt.write_empty_brackets()
}

write!(fmt.buf(), " {{")?;
Expand Down Expand Up @@ -2982,7 +2982,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {

if !is_first_stmt {
self.write_if_stmt(loc, cond, if_branch, else_branch)?;
return Ok(());
return Ok(())
}

self.context.if_stmt_single_line = Some(true);
Expand Down Expand Up @@ -3092,7 +3092,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {

if args.is_empty() {
write!(self.buf(), "({{}});")?;
return Ok(());
return Ok(())
}

write!(self.buf(), "(")?;
Expand All @@ -3112,7 +3112,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {

if expr.is_none() {
write_chunk!(self, loc.end(), "return;")?;
return Ok(());
return Ok(())
}

let expr = expr.as_mut().unwrap();
Expand All @@ -3129,7 +3129,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
expr.visit(fmt)
})?;
if fits_on_single {
return Ok(());
return Ok(())
}

let mut fit_on_next_line = false;
Expand All @@ -3146,7 +3146,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
})?;
if fit_on_next_line {
tx.commit()?;
return Ok(());
return Ok(())
}

write_return(fmt)?;
Expand Down Expand Up @@ -3234,7 +3234,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
let multiline = self.are_chunks_separated_multiline("{}", &chunks, "")?;
if !multiline {
self.write_chunks_separated(&chunks, "", false)?;
return Ok(());
return Ok(())
}

let mut chunks = chunks.iter_mut().peekable();
Expand Down

0 comments on commit 3018443

Please sign in to comment.