Skip to content

Commit 4ce3251

Browse files
authored
Fix clippy lints for Rust 1.88 (#377)
Fixes the lints for the bump to Rust 1.88
1 parent b05955e commit 4ce3251

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# TODO: track https://github.com/rust-lang/rust/issues/141626 for a resolution
2+
[target.x86_64-pc-windows-msvc]
3+
rustflags = ['-Csymbol-mangling-version=v0']

.github/workflows/rust.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,22 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
env:
15-
RUSTFLAGS: -Dwarnings
15+
FLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
1616
CARGO_TERM_COLOR: always
1717

1818
jobs:
1919
lint:
2020
name: Lint
2121
runs-on: ubuntu-latest
2222
steps:
23+
- name: Set environment
24+
# Setting `RUSTFLAGS` overrides any flags set on .cargo/config.toml, so we need to
25+
# set the target flags instead which are cumulative.
26+
# Track https://github.com/rust-lang/cargo/issues/5376
27+
run: |
28+
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
29+
echo "CARGO_TARGET_${target}_RUSTFLAGS=$FLAGS" >> $GITHUB_ENV
30+
2331
- uses: actions/checkout@v4
2432
- uses: dtolnay/rust-toolchain@stable
2533
with:
@@ -43,6 +51,11 @@ jobs:
4351
runs-on: ubuntu-latest
4452
timeout-minutes: 60
4553
steps:
54+
- name: Set environment
55+
run: |
56+
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
57+
echo "CARGO_TARGET_${target}_RUSTFLAGS=$FLAGS" >> $GITHUB_ENV
58+
4659
- name: Checkout repository
4760
uses: actions/checkout@v4
4861

@@ -61,6 +74,11 @@ jobs:
6174

6275
build-test:
6376
name: Test (${{ matrix.rust.name }}, ${{ matrix.os }})
77+
env:
78+
RUSTUP_WINDOWS_PATH_ADD_BIN: 1
79+
# NOTE: Boa comment mentions a small tool to handle this ... would be nice.
80+
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
81+
CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-D warnings' || '' }}
6482
strategy:
6583
matrix:
6684
rust:
@@ -86,6 +104,11 @@ jobs:
86104
name: Test feature matrix
87105
runs-on: ubuntu-latest
88106
steps:
107+
- name: Set environment
108+
run: |
109+
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
110+
echo "CARGO_TARGET_${target}_RUSTFLAGS=$FLAGS" >> $GITHUB_ENV
111+
89112
- uses: actions/checkout@v4
90113
- uses: dtolnay/rust-toolchain@master
91114
with:
@@ -110,6 +133,11 @@ jobs:
110133
os: [ubuntu-latest] # Todo: potentially add more if we add cpp tests
111134
runs-on: ${{ matrix.os }}
112135
steps:
136+
- name: Set environment
137+
run: |
138+
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
139+
echo "CARGO_TARGET_${target}_RUSTFLAGS=$FLAGS" >> $GITHUB_ENV
140+
113141
- uses: actions/checkout@v4
114142
- uses: dtolnay/rust-toolchain@master
115143
with:

src/primitive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl FiniteF64 {
2929
#[inline]
3030
pub fn negate(&self) -> Self {
3131
if !self.is_zero() {
32-
Self(self.0 * -1.0)
32+
Self(-self.0)
3333
} else {
3434
*self
3535
}

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn epoch_days_to_epoch_ms(day: i64, time: i64) -> i64 {
2828
/// returns a String representation of y suitable for inclusion in an ISO 8601 string
2929
pub(crate) fn pad_iso_year(year: i32) -> String {
3030
if (0..9999).contains(&year) {
31-
return format!("{:04}", year);
31+
return format!("{year:04}");
3232
}
3333
let year_sign = if year > 0 { "+" } else { "-" };
3434
let year_string = format!("{:06}", year.abs());

tools/zoneinfo-test-gen/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn generate_test_data(input_dir: PathBuf, output_dir: PathBuf, identifier: &str)
3030
let test_data_path = output_dir.join(format!("{filename}.json"));
3131

3232
let tzif_path = input_dir.join(identifier);
33-
std::println!("Parsing tzif from {:?}", tzif_path);
33+
std::println!("Parsing tzif from {tzif_path:?}");
3434
let tzif = tzif::parse_tzif_file(&tzif_path).unwrap();
3535

3636
let tzif_block_v2 = tzif.data_block2.unwrap();
@@ -71,7 +71,7 @@ fn generate_test_data(input_dir: PathBuf, output_dir: PathBuf, identifier: &str)
7171
transitions,
7272
};
7373

74-
std::println!("Writing generated example data to {:?}", test_data_path);
74+
std::println!("Writing generated example data to {test_data_path:?}");
7575
fs::write(
7676
test_data_path,
7777
serde_json::to_string_pretty(&tzif_data).unwrap(),

0 commit comments

Comments
 (0)