diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 74ad5c0d..9c44dfbd 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -17,7 +17,7 @@ jobs: - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.93.0 + toolchain: 1.95.0 override: true cache: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7fb1e4f..a22ccb92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.93.0 + toolchain: 1.95.0 components: clippy override: true - run: cargo clippy --all --all-features -- -D warnings @@ -54,13 +54,13 @@ jobs: - if: runner.os == 'macOS' uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.93.0 + toolchain: 1.95.0 target: aarch64-apple-darwin override: true - if: runner.os != 'macOS' uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.93.0 + toolchain: 1.95.0 override: true target: aarch64-unknown-linux-gnu - run: cargo test --release diff --git a/.github/workflows/preview-release.yaml b/.github/workflows/preview-release.yaml index 03186c92..1e975877 100644 --- a/.github/workflows/preview-release.yaml +++ b/.github/workflows/preview-release.yaml @@ -38,13 +38,13 @@ jobs: - if: runner.os == 'macOS' uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.93.0 + toolchain: 1.95.0 target: aarch64-apple-darwin override: true - if: runner.os != 'macOS' uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.93.0 + toolchain: 1.95.0 override: true target: aarch64-unknown-linux-gnu - run: ./script/make_release diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b13ac90e..e894c2b1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,13 +22,13 @@ jobs: - if: runner.os == 'macOS' uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.93.0 + toolchain: 1.95.0 target: aarch64-apple-darwin override: true - if: runner.os != 'macOS' uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.93.0 + toolchain: 1.95.0 override: true target: aarch64-unknown-linux-gnu - run: ./script/make_release diff --git a/librubyfmt/src/intermediary.rs b/librubyfmt/src/intermediary.rs index 80670b33..8f9d0d18 100644 --- a/librubyfmt/src/intermediary.rs +++ b/librubyfmt/src/intermediary.rs @@ -104,10 +104,10 @@ impl<'src> Intermediary<'src> { prev.set_gets_indented() } } - ConcreteLineToken::MethodName { name } => { - if *name == b"require" && self.tokens.last().is_some_and(|t| t.is_indent()) { - self.current_line_metadata.set_has_require(); - } + ConcreteLineToken::MethodName { name } + if *name == b"require" && self.tokens.last().is_some_and(|t| t.is_indent()) => + { + self.current_line_metadata.set_has_require(); } _ => {} } diff --git a/librubyfmt/src/line_tokens.rs b/librubyfmt/src/line_tokens.rs index 37ed0c48..aadf4f78 100644 --- a/librubyfmt/src/line_tokens.rs +++ b/librubyfmt/src/line_tokens.rs @@ -199,12 +199,8 @@ impl<'src> ConcreteLineToken<'src> { pub fn is_newline(&self) -> bool { match self { Self::HardNewLine => true, - Self::DirectPart { part } => { - if part.as_ref() == b"\n" { - panic!("shouldn't ever have a single newline direct part"); - } else { - false - } + Self::DirectPart { part } if part.as_ref() == b"\n" => { + panic!("shouldn't ever have a single newline direct part"); } _ => false, } diff --git a/librubyfmt/src/render_queue_writer.rs b/librubyfmt/src/render_queue_writer.rs index 41319250..1ad1f5b6 100644 --- a/librubyfmt/src/render_queue_writer.rs +++ b/librubyfmt/src/render_queue_writer.rs @@ -63,38 +63,33 @@ impl<'src> RenderQueueWriter<'src> { } ConcreteLineTokenAndTargets::ConcreteLineToken(ConcreteLineToken::Comment { contents, - }) => { - if !contents.is_empty() { - let indent = get_indent(accum.additional_indent as usize * 2); - let mut new_contents = indent.into_owned(); - new_contents.extend_from_slice(contents); - next_token = ConcreteLineTokenAndTargets::ConcreteLineToken( - ConcreteLineToken::Comment { - contents: new_contents.into(), - }, - ) - } + }) if !contents.is_empty() => { + let indent = get_indent(accum.additional_indent as usize * 2); + let mut new_contents = indent.into_owned(); + new_contents.extend_from_slice(contents); + next_token = + ConcreteLineTokenAndTargets::ConcreteLineToken(ConcreteLineToken::Comment { + contents: new_contents.into(), + }) } ConcreteLineTokenAndTargets::ConcreteLineToken(ConcreteLineToken::DirectPart { part, - }) => { - if current_heredoc_kind.is_some_and(|k| k.is_squiggly()) { - let indent = get_indent(accum.additional_indent as usize * 2); - let indent_bytes = indent.as_ref(); - let mut new_contents = Vec::new(); - let parts = part.split(|&b| b == b'\n'); + }) if current_heredoc_kind.is_some_and(|k| k.is_squiggly()) => { + let indent = get_indent(accum.additional_indent as usize * 2); + let indent_bytes = indent.as_ref(); + let mut new_contents = Vec::new(); + let parts = part.split(|&b| b == b'\n'); - for (i, p) in parts.enumerate() { - if i > 0 { - new_contents.push(b'\n'); - } - if !p.is_empty() { - new_contents.extend_from_slice(indent_bytes); - } - new_contents.extend_from_slice(p); + for (i, p) in parts.enumerate() { + if i > 0 { + new_contents.push(b'\n'); + } + if !p.is_empty() { + new_contents.extend_from_slice(indent_bytes); } - next_token = clats_direct_part(new_contents) + new_contents.extend_from_slice(p); } + next_token = clats_direct_part(new_contents) } ConcreteLineTokenAndTargets::ConcreteLineToken( ConcreteLineToken::HeredocStart { kind, .. }, diff --git a/src/main.rs b/src/main.rs index c803c16d..3f7fea12 100644 --- a/src/main.rs +++ b/src/main.rs @@ -422,24 +422,22 @@ fn main() { CommandlineOpts { in_place: true, .. } => { iterate_formatted(&opts, &|(file_path, before, after)| match after { - None => {} - Some(fmtted) => { - if fmtted.ne(before) { - let file_write = OpenOptions::new() - .write(true) - .truncate(true) - .open(file_path) - .and_then(|mut file| file.write_all(&fmtted)); - - match file_write { - Ok(_) => {} - Err(e) => handle_execution_error( - &opts, - ExecutionError::IOError(e, file_path.display().to_string()), - ), - } + Some(fmtted) if fmtted.ne(before) => { + let file_write = OpenOptions::new() + .write(true) + .truncate(true) + .open(file_path) + .and_then(|mut file| file.write_all(&fmtted)); + + match file_write { + Ok(_) => {} + Err(e) => handle_execution_error( + &opts, + ExecutionError::IOError(e, file_path.display().to_string()), + ), } } + _ => {} }) }