Skip to content

Commit

Permalink
Merge branch 'main' into refactor/sqlalchemy_oso_log_level
Browse files Browse the repository at this point in the history
  • Loading branch information
gj authored Nov 17, 2023
2 parents 968b271 + dcf3256 commit f1038a9
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion polar-c-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 4 additions & 6 deletions polar-core/src/data_filtering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ impl VarInfo {
}

fn do_and(self, args: &[Term]) -> PolarResult<Self> {
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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion polar-core/src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ mod to_polar {
if args.is_empty() {
kwargs
} else {
vec![args, kwargs].join(", ")
[args, kwargs].join(", ")
}
}
None => args,
Expand Down
10 changes: 5 additions & 5 deletions polar-core/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions polar-core/src/partial/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions polar-core/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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
},
)
Expand Down
4 changes: 2 additions & 2 deletions polar-core/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f1038a9

Please sign in to comment.