Skip to content

Commit 4e48134

Browse files
branchseerclaude
andcommitted
Fix clippy: expect attributes, map_or_else, safety comment
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e2fcef4 commit 4e48134

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

crates/vite_task_bin/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ fn main() -> ! {
1313
tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap().block_on(async {
1414
match run().await {
1515
Ok(status) => i32::from(status.0),
16+
#[expect(clippy::print_stderr, reason = "top-level error reporting")]
1617
Err(err) => {
1718
eprintln!("Error: {err:?}");
1819
1

crates/vite_task_bin/tests/e2e_snapshots/main.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,26 @@ impl Step {
8686
fn spawn_mode(&self) -> StepSpawn<'_> {
8787
match self {
8888
Self::Command(command) => StepSpawn::Shell(command.as_str()),
89-
Self::Detailed(config) => {
90-
if let Some(argv) = &config.argv {
91-
StepSpawn::Direct(argv)
92-
} else if let Some(command) = &config.command {
93-
StepSpawn::Shell(command.as_str())
94-
} else {
95-
panic!("step must have either 'command' or 'argv'");
96-
}
97-
}
89+
Self::Detailed(config) => config.argv.as_deref().map_or_else(
90+
|| {
91+
StepSpawn::Shell(
92+
config
93+
.command
94+
.as_ref()
95+
.expect("step must have either 'command' or 'argv'")
96+
.as_str(),
97+
)
98+
},
99+
StepSpawn::Direct,
100+
),
98101
}
99102
}
100103

104+
#[expect(clippy::disallowed_types, reason = "String required by join")]
101105
fn display_command(&self) -> String {
102106
match self.spawn_mode() {
103107
StepSpawn::Shell(cmd) => cmd.to_string(),
104-
StepSpawn::Direct(argv) => {
105-
argv.iter().map(|a| a.as_str()).collect::<Vec<_>>().join(" ")
106-
}
108+
StepSpawn::Direct(argv) => argv.iter().map(Str::as_str).collect::<Vec<_>>().join(" "),
107109
}
108110
}
109111

@@ -467,12 +469,12 @@ fn run_case_inner(tmpdir: &AbsolutePath, fixture_path: &std::path::Path, fixture
467469
}
468470

469471
fn main() {
470-
// SAFETY: Called before any threads are spawned; insta reads this lazily on first assertion.
471472
// Skip INSTA_REQUIRE_FULL_MATCH when running cross-platform (via cargo-xtest): the snapshot
472473
// source metadata changes when the test binary runs on a remote machine, causing insta to
473474
// write .snap.new even when content matches. INSTA_UPDATE=always in this mode accepts
474475
// metadata-only changes.
475476
if std::env::var_os("INSTA_UPDATE").is_none() {
477+
// SAFETY: Called before any threads are spawned; insta reads this lazily on first assertion.
476478
unsafe { std::env::set_var("INSTA_REQUIRE_FULL_MATCH", "1") };
477479
}
478480

0 commit comments

Comments
 (0)