Skip to content

Commit a963064

Browse files
committed
style(rust-cli): fix clippy 1.97 + rustfmt for CI green
CI (Rust 1.97) failed two checks on this branch: - rustfmt: new test files + the Obliterate executor arm needed formatting. - clippy -D warnings: unneeded_wildcard_pattern (field: _ redundant with ..) in commands.rs (Chmod/Chown) and parser.rs (External/Touch), which clippy 1.97 newly errors on; plus a pre-existing let_and_return in the ${VAR:=default} expansion path. Fixes: - cargo fmt across the crate (new tests + executable.rs). - Remove redundant bindings where already covers them. - Inline the let-and-return in AssignDefault expansion (behavior unchanged). Verified against CI's exact toolchain: cargo +1.97.0 clippy --all-targets --all-features -- -D warnings is clean; cargo +1.97.0 fmt --check has 0 diffs. Full lib suite (317) + obliterate RMO tests (6) still green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KfgJznd6jzSeDYsSXGAXkU
1 parent 4883a42 commit a963064

5 files changed

Lines changed: 50 additions & 18 deletions

File tree

impl/rust-cli/src/commands.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,8 +2233,7 @@ pub fn explain_command(cmd: &crate::parser::Command, state: &ShellState) -> Resu
22332233
resolved.display()
22342234
);
22352235
}
2236-
crate::parser::Command::Chmod { path: _, .. }
2237-
| crate::parser::Command::Chown { path: _, .. } => {
2236+
crate::parser::Command::Chmod { .. } | crate::parser::Command::Chown { .. } => {
22382237
// Outer arm guarantees we are in {Chmod, Chown}; the inner match
22392238
// exists only to extract the `path` field uniformly. Any other
22402239
// variant here is a structural bug, surfaced as typed error.

impl/rust-cli/src/executable.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ impl ExecutableCommand for Command {
129129
} => {
130130
let expanded_path = crate::parser::expand_variables(path, state);
131131
if redirects.is_empty() {
132-
commands::secure_deletion::obliterate_path(state, &expanded_path, false, *force)?;
132+
commands::secure_deletion::obliterate_path(
133+
state,
134+
&expanded_path,
135+
false,
136+
*force,
137+
)?;
133138
} else {
134139
redirection::capture_and_redirect(redirects, state, |s| {
135140
commands::secure_deletion::obliterate_path(s, &expanded_path, false, *force)

impl/rust-cli/src/parser.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,10 +2264,9 @@ fn apply_expansion(expansion: &ParameterExpansion, state: &crate::state::ShellSt
22642264
// TODO: Assignment not implemented - requires mutable state
22652265
// For v1.1.0, just return default without assigning (like Default)
22662266
if is_unset || (*check_null && is_null) {
2267-
let default_expanded = expand_variables(value, state);
2268-
// Note: In bash, this would also assign to VAR
2267+
// Note: In bash, this would also assign to VAR.
22692268
// Requires signature change: &mut ShellState
2270-
default_expanded
2269+
expand_variables(value, state)
22712270
} else {
22722271
// var_value is Some by construction here: the surrounding
22732272
// `if is_unset || ...` branch is the unset/null path; this
@@ -4346,7 +4345,7 @@ mod tests {
43464345
// Test using $1 in a command
43474346
let cmd = parse_command("touch $1").unwrap();
43484347
match cmd {
4349-
Command::External { args: _, .. } | Command::Touch { path: _, .. } => {
4348+
Command::External { .. } | Command::Touch { .. } => {
43504349
// After parsing, before execution, $1 should still be present
43514350
// Expansion happens during execution
43524351
}

impl/rust-cli/tests/model_oracle_correspondence.rs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ fn gen_sequence(rng: &mut Rng, max_ops: usize) -> (Vec<Op>, Vec<String>) {
131131
}
132132
shadow.insert(p.clone(), Kind::Dir);
133133
touched.insert(p.clone(), ());
134-
ops.push(Op { verb: "MKDIR", path: p });
134+
ops.push(Op {
135+
verb: "MKDIR",
136+
path: p,
137+
});
135138
} else if roll < 8 {
136139
// TOUCH under an existing directory
137140
let ds = dirs(&shadow);
@@ -143,7 +146,10 @@ fn gen_sequence(rng: &mut Rng, max_ops: usize) -> (Vec<Op>, Vec<String>) {
143146
}
144147
shadow.insert(p.clone(), Kind::File);
145148
touched.insert(p.clone(), ());
146-
ops.push(Op { verb: "TOUCH", path: p });
149+
ops.push(Op {
150+
verb: "TOUCH",
151+
path: p,
152+
});
147153
} else if roll < 9 {
148154
// RM an existing file
149155
let files: Vec<String> = shadow
@@ -157,7 +163,10 @@ fn gen_sequence(rng: &mut Rng, max_ops: usize) -> (Vec<Op>, Vec<String>) {
157163
let p = files[rng.below(files.len())].clone();
158164
shadow.remove(&p);
159165
touched.insert(p.clone(), ());
160-
ops.push(Op { verb: "RM", path: p });
166+
ops.push(Op {
167+
verb: "RM",
168+
path: p,
169+
});
161170
} else {
162171
// RMDIR an empty directory
163172
let empties: Vec<String> = shadow
@@ -171,7 +180,10 @@ fn gen_sequence(rng: &mut Rng, max_ops: usize) -> (Vec<Op>, Vec<String>) {
171180
let p = empties[rng.below(empties.len())].clone();
172181
shadow.remove(&p);
173182
touched.insert(p.clone(), ());
174-
ops.push(Op { verb: "RMDIR", path: p });
183+
ops.push(Op {
184+
verb: "RMDIR",
185+
path: p,
186+
});
175187
}
176188
}
177189

@@ -260,7 +272,10 @@ fn rust_matches_proven_lean_model() {
260272
_ => unreachable!(),
261273
};
262274
r.unwrap_or_else(|e| {
263-
panic!("seq {seq}: generated op {} {} rejected by impl: {e}", op.verb, op.path)
275+
panic!(
276+
"seq {seq}: generated op {} {} rejected by impl: {e}",
277+
op.verb, op.path
278+
)
264279
});
265280
}
266281

@@ -278,11 +293,14 @@ fn rust_matches_proven_lean_model() {
278293
for (probe, model_kind) in probes.iter().zip(model.iter()) {
279294
let impl_kind = rust_kind(temp.path(), probe);
280295
assert_eq!(
281-
model_kind, impl_kind,
296+
model_kind,
297+
impl_kind,
282298
"CORRESPONDENCE DIVERGENCE (seq {seq}) at '{probe}': \
283299
proven Lean model says {model_kind}, Rust impl says {impl_kind}.\n\
284300
ops: {:?}",
285-
ops.iter().map(|o| format!("{} {}", o.verb, o.path)).collect::<Vec<_>>()
301+
ops.iter()
302+
.map(|o| format!("{} {}", o.verb, o.path))
303+
.collect::<Vec<_>>()
286304
);
287305
checked_probes += 1;
288306
}
@@ -292,5 +310,7 @@ fn rust_matches_proven_lean_model() {
292310
checked_probes > 0,
293311
"no probes were checked — generator produced only empty sequences"
294312
);
295-
eprintln!("model_oracle_correspondence: {checked_probes} probes agreed across {SEQUENCES} sequences");
313+
eprintln!(
314+
"model_oracle_correspondence: {checked_probes} probes agreed across {SEQUENCES} sequences"
315+
);
296316
}

impl/rust-cli/tests/obliterate_rmo_tests.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ fn obliterate_is_wired_into_dispatch() {
3333
}
3434

3535
// --force before or after the path both work.
36-
for input in ["obliterate --force secret.txt", "obliterate secret.txt --force"] {
36+
for input in [
37+
"obliterate --force secret.txt",
38+
"obliterate secret.txt --force",
39+
] {
3740
match parse_command(input).expect("parse") {
3841
Command::Obliterate { path, force, .. } => {
3942
assert_eq!(path, "secret.txt", "input: {input}");
@@ -79,7 +82,10 @@ fn obliterate_writes_rmo_audit_residue() {
7982
.expect("execute");
8083

8184
let audit = temp.path().join(".vsh-audit.log");
82-
assert!(audit.exists(), "RMO audit residue must be written to the sandbox");
85+
assert!(
86+
audit.exists(),
87+
"RMO audit residue must be written to the sandbox"
88+
);
8389
let contents = fs::read_to_string(&audit).expect("read audit");
8490
assert!(
8591
contents.contains("Obliterate"),
@@ -130,5 +136,8 @@ fn obliterate_then_recreate_has_no_old_content() {
130136
fs::write(&p, b"fresh").expect("rewrite");
131137
let back = fs::read(&p).expect("read");
132138
assert_eq!(back, b"fresh");
133-
assert!(!back.windows(4).any(|w| w == b"4111"), "no old plaintext remains");
139+
assert!(
140+
!back.windows(4).any(|w| w == b"4111"),
141+
"no old plaintext remains"
142+
);
134143
}

0 commit comments

Comments
 (0)