Skip to content

Commit 44265de

Browse files
authored
Bump CI rust toolchain to 1.85.0 (#477)
* Bump CI rust toolchain to 1.85.0 * Also bump actions-rs/toolchain to a supported version * Fix clippy failures * Fix clippy violations
1 parent 06f1c8e commit 44265de

File tree

9 files changed

+35
-50
lines changed

9 files changed

+35
-50
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v1
19-
- uses: actions-rs/toolchain@v1
19+
- uses: actions-rust-lang/setup-rust-toolchain@v1
2020
with:
2121
toolchain: stable
2222
components: rustfmt
2323
override: true
24-
profile: minimal
2524
- uses: actions-rs/cargo@v1
2625
with:
2726
command: fmt
@@ -31,12 +30,11 @@ jobs:
3130
runs-on: ubuntu-latest
3231
steps:
3332
- uses: actions/checkout@v1
34-
- uses: actions-rs/toolchain@v1
33+
- uses: actions-rust-lang/setup-rust-toolchain@v1
3534
with:
36-
toolchain: 1.63.0
35+
toolchain: 1.85.0
3736
components: clippy
3837
override: true
39-
profile: minimal
4038
- run: cargo clippy --all --all-features -- -D warnings
4139

4240
lint:
@@ -67,19 +65,16 @@ jobs:
6765
with:
6866
submodules: true
6967
- if: runner.os == 'macOS'
70-
uses: actions-rs/toolchain@v1
68+
uses: actions-rust-lang/setup-rust-toolchain@v1
7169
with:
72-
toolchain: 1.63.0
70+
toolchain: 1.85.0
7371
target: aarch64-apple-darwin
74-
default: true
7572
override: true
76-
profile: minimal
7773
- if: runner.os != 'macOS'
78-
uses: actions-rs/toolchain@v1
74+
uses: actions-rust-lang/setup-rust-toolchain@v1
7975
with:
80-
toolchain: 1.63.0
76+
toolchain: 1.85.0
8177
override: true
82-
profile: minimal
8378
target: aarch64-unknown-linux-gnu
8479
- uses: actions/cache@v4
8580
with:

.github/workflows/preview-release.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,16 @@ jobs:
4949
submodules: true
5050
fetch-depth: 0
5151
- if: runner.os == 'macOS'
52-
uses: actions-rs/toolchain@v1
52+
uses: actions-rust-lang/setup-rust-toolchain@v1
5353
with:
54-
toolchain: 1.63.0
54+
toolchain: 1.85.0
5555
target: aarch64-apple-darwin
56-
default: true
5756
override: true
58-
profile: minimal
5957
- if: runner.os != 'macOS'
60-
uses: actions-rs/toolchain@v1
58+
uses: actions-rust-lang/setup-rust-toolchain@v1
6159
with:
62-
toolchain: 1.63.0
60+
toolchain: 1.85.0
6361
override: true
64-
profile: minimal
6562
target: aarch64-unknown-linux-gnu
6663
- if: runner.os == 'macOS'
6764
run: |

.github/workflows/release.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,16 @@ jobs:
2929
submodules: true
3030
fetch-depth: 0
3131
- if: runner.os == 'macOS'
32-
uses: actions-rs/toolchain@v1
32+
uses: actions-rust-lang/setup-rust-toolchain@v1
3333
with:
34-
toolchain: 1.63.0
34+
toolchain: 1.85.0
3535
target: aarch64-apple-darwin
36-
default: true
3736
override: true
38-
profile: minimal
3937
- if: runner.os != 'macOS'
40-
uses: actions-rs/toolchain@v1
38+
uses: actions-rust-lang/setup-rust-toolchain@v1
4139
with:
42-
toolchain: 1.63.0
40+
toolchain: 1.85.0
4341
override: true
44-
profile: minimal
4542
target: aarch64-unknown-linux-gnu
4643
- if: runner.os == 'macOS'
4744
run: |

librubyfmt/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn main() -> Output {
4040
};
4141

4242
let _ = Command::new("git")
43-
.args(&["submodule", "update", "--init"])
43+
.args(["submodule", "update", "--init"])
4444
.status();
4545

4646
let new_checkout_sha = get_ruby_checkout_sha();
@@ -59,7 +59,7 @@ fn main() -> Output {
5959

6060
cc::Build::new()
6161
.file("src/rubyfmt.c")
62-
.object(ruby_checkout_path.join(&ripper))
62+
.object(ruby_checkout_path.join(ripper))
6363
.include(ruby_checkout_path.join("include"))
6464
.include(ruby_checkout_path.join(format!(".ext/include/{}", arch)))
6565
.warnings(false)
@@ -229,7 +229,7 @@ fn check_process_success(command: &str, code: ExitStatus) -> Output {
229229
fn get_ruby_checkout_sha() -> String {
230230
String::from_utf8(
231231
Command::new("git")
232-
.args(&["rev-parse", "HEAD"])
232+
.args(["rev-parse", "HEAD"])
233233
.current_dir("./ruby_checkout")
234234
.output()
235235
.expect("git rev-parse shouldn't fail")

librubyfmt/src/de.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'de> de::Deserialize<'de> for VALUE {
6969

7070
struct Visitor;
7171

72-
impl<'de> de::Visitor<'de> for Visitor {
72+
impl de::Visitor<'_> for Visitor {
7373
type Value = VALUE;
7474

7575
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {

librubyfmt/src/format.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,7 +2519,7 @@ fn format_binary_inner(ps: &mut dyn ConcreteParserState, binary: Binary) {
25192519
}));
25202520
}
25212521

2522-
let comparison_operators = vec![">", ">=", "===", "==", "<", "<=", "<=>", "!="];
2522+
let comparison_operators = [">", ">=", "===", "==", "<", "<=", "<=>", "!="];
25232523
let is_not_comparison = !comparison_operators.iter().any(|o| o == &op.0);
25242524

25252525
let next_expr = *binary.3;
@@ -2695,7 +2695,7 @@ fn can_elide_parens_for_reserved_names(cc: &[CallChainElement]) -> bool {
26952695
.iter()
26962696
.any(|e| matches!(e, CallChainElement::DotTypeOrOp(..)));
26972697
let is_bare_reserved_method_name = is_bare_call
2698-
&& match cc.get(0) {
2698+
&& match cc.first() {
26992699
Some(CallChainElement::IdentOrOpOrKeywordOrConst(
27002700
IdentOrOpOrKeywordOrConst::Ident(Ident(_, ident, _)),
27012701
)) => {
@@ -2709,7 +2709,7 @@ fn can_elide_parens_for_reserved_names(cc: &[CallChainElement]) -> bool {
27092709
return true;
27102710
}
27112711

2712-
let is_rspec_describe = match (cc.get(0), cc.get(2)) {
2712+
let is_rspec_describe = match (cc.first(), cc.get(2)) {
27132713
(
27142714
Some(CallChainElement::VarRef(VarRef(_, VarRefType::Const(Const(_, c, _))))),
27152715
Some(CallChainElement::IdentOrOpOrKeywordOrConst(IdentOrOpOrKeywordOrConst::Ident(
@@ -2903,7 +2903,7 @@ pub fn format_method_add_block(ps: &mut dyn ConcreteParserState, mab: MethodAddB
29032903
}
29042904
}
29052905

2906-
pub fn is_empty_bodystmt(bodystmt: &Vec<Expression>) -> bool {
2906+
pub fn is_empty_bodystmt(bodystmt: &[Expression]) -> bool {
29072907
bodystmt.len() == 1 && matches!(bodystmt[0], Expression::VoidStmt(..))
29082908
}
29092909

@@ -3024,7 +3024,7 @@ fn get_brace_block_render_method(
30243024
ps: &mut dyn ConcreteParserState,
30253025
start_line: u64,
30263026
end_line: u64,
3027-
body: &Vec<Expression>,
3027+
body: &[Expression],
30283028
) -> BraceBlockRenderMethod {
30293029
let has_multiple_expressions = body.len() > 1;
30303030
if has_multiple_expressions {
@@ -3132,12 +3132,12 @@ pub fn format_keyword(
31323132

31333133
pub fn format_while(
31343134
ps: &mut dyn ConcreteParserState,
3135-
conditional: Box<Expression>,
3135+
conditional: Expression,
31363136
exprs: Vec<Expression>,
31373137
kw: String,
31383138
start_end: StartEnd,
31393139
) {
3140-
format_conditional(ps, *conditional, exprs, kw, None, Some(start_end));
3140+
format_conditional(ps, conditional, exprs, kw, None, Some(start_end));
31413141

31423142
ps.with_start_of_line(
31433143
true,
@@ -3751,8 +3751,8 @@ pub fn format_expression(ps: &mut dyn ConcreteParserState, expression: Expressio
37513751
Expression::Yield(y) => format_yield(ps, y),
37523752
Expression::Break(b) => format_keyword(ps, b.1, "break".to_string(), b.2),
37533753
Expression::MethodAddBlock(mab) => format_method_add_block(ps, mab),
3754-
Expression::While(w) => format_while(ps, w.1, w.2, "while".to_string(), w.3),
3755-
Expression::Until(u) => format_while(ps, u.1, u.2, "until".to_string(), u.3),
3754+
Expression::While(w) => format_while(ps, *w.1, w.2, "while".to_string(), w.3),
3755+
Expression::Until(u) => format_while(ps, *u.1, u.2, "until".to_string(), u.3),
37563756
Expression::WhileMod(wm) => format_inline_mod(ps, wm.1, wm.2, "while".to_string()),
37573757
Expression::UntilMod(um) => format_inline_mod(ps, um.1, um.2, "until".to_string()),
37583758
Expression::IfMod(wm) => format_multilinable_mod(ps, wm.1, wm.2, "if".to_string()),

librubyfmt/src/heredoc_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ impl HeredocString {
8181
/// quotes, so we must strip them from the symbol when
8282
/// rendering the closing symbol.
8383
pub fn closing_symbol(&self) -> String {
84-
self.symbol.replace('\'', "").replace('"', "")
84+
self.symbol.replace(['\'', '"'], "")
8585
}
8686
}

librubyfmt/src/parser_state.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,7 @@ impl ConcreteParserState for BaseParserState {
799799
}
800800

801801
fn render_heredocs(&mut self, skip: bool) {
802-
while !self.heredoc_strings.is_empty() {
803-
let next_heredoc = self.heredoc_strings.pop().expect("we checked it's there");
802+
while let Some(next_heredoc) = self.heredoc_strings.pop() {
804803
let want_newline = !self.last_token_is_a_newline();
805804
if want_newline {
806805
self.push_concrete_token(ConcreteLineToken::HardNewLine);
@@ -879,12 +878,8 @@ impl BaseParserState {
879878
None
880879
} else {
881880
let mut hds = vec![];
882-
while !self.heredoc_strings.is_empty() {
883-
hds.push(
884-
self.heredoc_strings
885-
.pop()
886-
.expect("we checked it's not empty"),
887-
);
881+
while let Some(element) = self.heredoc_strings.pop() {
882+
hds.push(element);
888883
}
889884
Some(hds)
890885
}

src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct CommandlineOpts {
7070
/// - File paths (i.e lib/foo/bar.rb){n}
7171
/// - Directories (i.e. lib/foo/){n}
7272
/// - Input files (i.e. @/tmp/files.txt). These files must contain one file path or directory per line
73+
///
7374
/// rubyfmt will use these as input.{n}
7475
#[clap(name = "include-paths")]
7576
include_paths: Vec<String>,
@@ -79,7 +80,7 @@ struct CommandlineOpts {
7980
/* Error handling */
8081
/******************************************************/
8182

82-
fn handle_io_error(err: io::Error, source: &String, error_exit: ErrorExit) {
83+
fn handle_io_error(err: io::Error, source: &str, error_exit: ErrorExit) {
8384
let msg = format!("Rubyfmt experienced an IO error: {}", err);
8485
print_error(&msg, Some(source));
8586

@@ -96,7 +97,7 @@ fn handle_ignore_error(err: ignore::Error, error_exit: ErrorExit) {
9697
}
9798
}
9899

99-
fn handle_rubyfmt_error(err: rubyfmt::RichFormatError, source: &String, error_exit: ErrorExit) {
100+
fn handle_rubyfmt_error(err: rubyfmt::RichFormatError, source: &str, error_exit: ErrorExit) {
100101
use rubyfmt::RichFormatError::*;
101102
let exit_code = err.as_exit_code();
102103
let e = || {

0 commit comments

Comments
 (0)