diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 00ba1a9eae..aec2b3424a 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -22,7 +22,7 @@ jobs: remote-repository-name: cla-signatures path-to-signatures: individual.json branch: main - allowlist: djanatyn,gj,gneray,jedgresham,killpack,laxjesse,patrickod,samscott89,ssglaser,uncommoncense,vrama628,dependabot,dependabot[bot] + allowlist: djanatyn,edaniels,gj,gneray,gsarjeant,jedgresham,killpack,laxjesse,orez-,samscott89,ssglaser,sverch,uncommoncense,vrama628,dependabot,dependabot[bot] use-dco-flag: false create-file-commit-message: 'Creating file for storing CLA signatures' signed-commit-message: '$contributorName has signed the CLA in osohq/oso#$pullRequestNo' diff --git a/polar-c-api/src/lib.rs b/polar-c-api/src/lib.rs index 98c356862b..f88c4ea1bd 100644 --- a/polar-c-api/src/lib.rs +++ b/polar-c-api/src/lib.rs @@ -329,7 +329,9 @@ pub extern "C" fn string_free(s: *mut c_char) -> i32 { if s.is_null() { return POLAR_FAILURE; } - unsafe { CString::from_raw(s) }; + unsafe { + let _ = CString::from_raw(s); + }; POLAR_SUCCESS } diff --git a/polar-core/src/data_filtering.rs b/polar-core/src/data_filtering.rs index 21b9969320..326ca062a9 100644 --- a/polar-core/src/data_filtering.rs +++ b/polar-core/src/data_filtering.rs @@ -211,9 +211,8 @@ impl VarInfo { } fn do_and(self, args: &[Term]) -> PolarResult { - args.iter().fold(Ok(self), |this, arg| { - this?.process_exp(arg.as_expression()?) - }) + args.iter() + .try_fold(self, |this, arg| this.process_exp(arg.as_expression()?)) } fn do_dot(mut self, lhs: &Term, rhs: &Term) -> Self { @@ -795,8 +794,7 @@ impl<'a> ResultSetBuilder<'a> { fn constrain_fields(&mut self, id: Id, var_type: &str) -> PolarResult<&mut Self> { match self.vars.field_relationships.get(&id) { None => Ok(self), - Some(fs) => fs.iter().fold(Ok(self), |this, (field, child)| { - let this = this?; + Some(fs) => fs.iter().try_fold(self, |this, (field, child)| { match this.types.get(var_type).and_then(|m| m.get(field)) { None => df_field_missing(var_type, field), Some(Type::Relation { @@ -991,7 +989,7 @@ where A: Eq + Hash, B: Eq + Hash, { - map.entry(a).or_insert_with(HashSet::new).insert(b); + map.entry(a).or_default().insert(b); map } diff --git a/polar-core/src/formatting.rs b/polar-core/src/formatting.rs index eb30b7b6a1..af4ddba36a 100644 --- a/polar-core/src/formatting.rs +++ b/polar-core/src/formatting.rs @@ -574,7 +574,7 @@ mod to_polar { if args.is_empty() { kwargs } else { - vec![args, kwargs].join(", ") + [args, kwargs].join(", ") } } None => args, diff --git a/polar-core/src/lexer.rs b/polar-core/src/lexer.rs index c97b197778..1f1ec81754 100644 --- a/polar-core/src/lexer.rs +++ b/polar-core/src/lexer.rs @@ -518,14 +518,14 @@ mod tests { lexer.next(), Some(Ok((_, Token::Integer(123), _))) )); - assert!(matches!(lexer.next(), None)); + assert!(lexer.next().is_none()); let s = "123 #comment"; let mut lexer = Lexer::new(s); assert!(matches!( lexer.next(), Some(Ok((_, Token::Integer(123), _))) )); - assert!(matches!(lexer.next(), None)); + assert!(lexer.next().is_none()); } #[test] @@ -595,14 +595,14 @@ mod tests { assert!( matches!(lexer.next(), Some(Ok((4, Token::Symbol(x), 7))) if x == Symbol::new("bar")) ); - assert!(matches!(lexer.next(), None)); + assert!(lexer.next().is_none()); let s = "foo::bar"; let mut lexer = Lexer::new(s); assert!( matches!(lexer.next(), Some(Ok((0, Token::Symbol(x), 8))) if x == Symbol::new("foo::bar")) ); - assert!(matches!(lexer.next(), None)); + assert!(lexer.next().is_none()); let s = "foo:::bar"; let mut lexer = Lexer::new(s); @@ -651,7 +651,7 @@ mod tests { assert!( matches!(lexer.next(), Some(Ok((66, Token::Symbol(ruby_namespace), 81))) if ruby_namespace == Symbol::new("Ruby::Namespace")) ); - assert!(matches!(lexer.next(), None)); + assert!(lexer.next().is_none()); } #[test] diff --git a/polar-core/src/partial/simplify.rs b/polar-core/src/partial/simplify.rs index db76f83029..da634df0ea 100644 --- a/polar-core/src/partial/simplify.rs +++ b/polar-core/src/partial/simplify.rs @@ -286,8 +286,8 @@ impl PerfCounters { return; } - self.simplify_term.extend(other.simplify_term.into_iter()); - self.preprocess_and.extend(other.preprocess_and.into_iter()); + self.simplify_term.extend(other.simplify_term); + self.preprocess_and.extend(other.preprocess_and); } pub fn is_enabled(&self) -> bool { diff --git a/polar-core/src/rules.rs b/polar-core/src/rules.rs index d65a3d7a5e..a88b358e71 100644 --- a/polar-core/src/rules.rs +++ b/polar-core/src/rules.rs @@ -122,7 +122,7 @@ impl RuleTypes { pub fn add(&mut self, rule_type: Rule) { let name = rule_type.name.clone(); // get rule types with this rule name - let rule_types = self.0.entry(name).or_insert_with(Vec::new); + let rule_types = self.0.entry(name).or_default(); rule_types.push(rule_type); } @@ -161,7 +161,7 @@ impl RuleIndex { None } }) - .or_insert_with(RuleIndex::default) + .or_default() .index_rule(rule_id, params, i + 1); } else { self.rules.insert(rule_id); @@ -180,8 +180,8 @@ impl RuleIndex { let mut ruleset = self .index .get(&Some(arg.clone())) - .map(|index| filter_next_args(index)) - .unwrap_or_else(RuleSet::default); + .map(filter_next_args) + .unwrap_or_default(); // Extend for a variable parameter. if let Some(index) = self.index.get(&None) { @@ -193,7 +193,7 @@ impl RuleIndex { self.index.values().fold( RuleSet::default(), |mut result: RuleSet, index: &RuleIndex| { - result.extend(filter_next_args(index).into_iter()); + result.extend(filter_next_args(index)); result }, ) diff --git a/polar-core/src/vm.rs b/polar-core/src/vm.rs index daacb57f91..74f4cdbabd 100644 --- a/polar-core/src/vm.rs +++ b/polar-core/src/vm.rs @@ -832,7 +832,7 @@ impl PolarVirtualMachine { trace = trace_stack .pop() .map(|ts| ts.as_ref().clone()) - .unwrap_or_else(Vec::new); + .unwrap_or_default(); } stack.reverse(); @@ -1261,7 +1261,7 @@ impl PolarVirtualMachine { }); let mut add_constraints = vec![type_constraint]; - add_constraints.extend(field_constraints.into_iter()); + add_constraints.extend(field_constraints); // Run compatibility check. self.choose_conditional(