Skip to content

Commit 5cffa1e

Browse files
anakrishCopilot
andcommitted
style: satisfy clippy on new tests and pair destructuring
- src/rvm/vm/loops.rs: destructure pairs.get(*pos) via .0/.1 to avoid pattern_type_mismatch on the &(Value, Value) reference. - src/rvm/vm/context.rs: add the standard test-module clippy allows (expect_used, unwrap_used, unreachable, pattern_type_mismatch, shadow_unrelated, panic) and rename the local snapshot to avoid shadowing the IterationState::Object field name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5c4b678 commit 5cffa1e

6 files changed

Lines changed: 17 additions & 8 deletions

File tree

bindings/ffi/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/java/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/python/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/wasm/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rvm/vm/context.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ pub(super) struct ComprehensionContext {
9999
}
100100

101101
#[cfg(test)]
102+
#[allow(
103+
clippy::expect_used,
104+
clippy::unwrap_used,
105+
clippy::unreachable,
106+
clippy::pattern_type_mismatch,
107+
clippy::shadow_unrelated,
108+
clippy::panic
109+
)]
102110
mod tests {
103111
use super::*;
104112
use crate::collections::Object;
@@ -116,7 +124,7 @@ mod tests {
116124
let source = Value::Object(Rc::new(obj));
117125

118126
// Build the snapshot exactly as loops.rs / comprehension.rs do.
119-
let pairs: Rc<[(Value, Value)]> = match &source {
127+
let snapshot_pairs: Rc<[(Value, Value)]> = match &source {
120128
Value::Object(o) => o
121129
.iter()
122130
.map(|(k, v)| (k.clone(), v.clone()))
@@ -125,7 +133,7 @@ mod tests {
125133
_ => unreachable!(),
126134
};
127135
let state = IterationState::Object {
128-
pairs: Rc::clone(&pairs),
136+
pairs: Rc::clone(&snapshot_pairs),
129137
pos: 0,
130138
};
131139

@@ -145,7 +153,7 @@ mod tests {
145153
assert!(collected.contains(&(Value::from("a"), Value::from(1))));
146154
assert!(collected.contains(&(Value::from("b"), Value::from(2))));
147155
assert!(collected.contains(&(Value::from("c"), Value::from(3))));
148-
assert!(!collected.iter().any(|(k, _)| k == &Value::from("d")));
156+
assert!(!collected.iter().any(|kv| kv.0 == Value::from("d")));
149157

150158
// The original source Value (untouched) is also unchanged.
151159
let src_obj = source.as_object().expect("object");

src/rvm/vm/loops.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ impl RegoVM {
510510
}
511511
}
512512
IterationState::Object { ref pairs, ref pos } => {
513-
if let Some((key, value)) = pairs.get(*pos) {
513+
if let Some(pair) = pairs.get(*pos) {
514+
let (key, value) = (&pair.0, &pair.1);
514515
if key_reg != value_reg {
515516
self.set_register(key_reg, key.clone())?;
516517
}

0 commit comments

Comments
 (0)