Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/preview-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions librubyfmt/src/intermediary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
_ => {}
}
Expand Down
8 changes: 2 additions & 6 deletions librubyfmt/src/line_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
47 changes: 21 additions & 26 deletions librubyfmt/src/render_queue_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, .. },
Expand Down
30 changes: 14 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
),
}
}
_ => {}
})
}

Expand Down