Skip to content

Commit

Permalink
Fix errors reported by lint #![deny(rust_2018_idioms)]
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr committed Mar 13, 2024
1 parent 2c15d0d commit f9c7bba
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 69 deletions.
8 changes: 4 additions & 4 deletions extension/partiql-extension-ion-functions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub(crate) struct EvalFnReadIon {}
impl BaseTableExpr for EvalFnReadIon {
fn evaluate<'c>(
&self,
args: &[Cow<Value>],
args: &[Cow<'_, Value>],
_ctx: &'c dyn SessionContext<'c>,
) -> BaseTableExprResult<'c> {
if let Some(arg1) = args.first() {
Expand Down Expand Up @@ -158,7 +158,7 @@ fn parse_ion_buff<'a, I: 'a + ToIonDataSource>(input: I) -> BaseTableExprResult<
let decoder =
IonDecoderBuilder::new(IonDecoderConfig::default().with_mode(Encoding::Ion)).build(reader);
let decoder = decoder.map_err(err_map)?.map(move |it| it.map_err(err_map));
Ok(Box::new(decoder) as BaseTableExprResultValueIter)
Ok(Box::new(decoder) as BaseTableExprResultValueIter<'_>)
}

#[cfg(test)]
Expand All @@ -175,15 +175,15 @@ mod tests {

#[track_caller]
#[inline]
pub(crate) fn parse(statement: &str) -> ParserResult {
pub(crate) fn parse(statement: &str) -> ParserResult<'_> {
partiql_parser::Parser::default().parse(statement)
}

#[track_caller]
#[inline]
pub(crate) fn lower(
catalog: &dyn Catalog,
parsed: &Parsed,
parsed: &Parsed<'_>,
) -> partiql_logical::LogicalPlan<partiql_logical::BindingsOp> {
let planner = partiql_logical_planner::LogicalPlanner::new(catalog);
planner.lower(parsed).expect("lower")
Expand Down
2 changes: 0 additions & 2 deletions extension/partiql-extension-ion/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ where

struct SimpleIonValueEncoder<'a, W, I>
where
W: 'a,
I: IonWriter<Output = W>,
{
pub(crate) writer: &'a mut I,
Expand Down Expand Up @@ -311,7 +310,6 @@ where

struct PartiqlEncodedIonValueEncoder<'a, W, I>
where
W: 'a,
I: IonWriter<Output = W>,
{
inner: SimpleIonValueEncoder<'a, W, I>,
Expand Down
4 changes: 2 additions & 2 deletions partiql-catalog/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use std::any::Any;
use std::fmt::Debug;

pub trait Bindings<T>: Debug {
fn get(&self, name: &BindingsName) -> Option<&T>;
fn get(&self, name: &BindingsName<'_>) -> Option<&T>;
}

impl Bindings<Value> for Tuple {
fn get(&self, name: &BindingsName) -> Option<&Value> {
fn get(&self, name: &BindingsName<'_>) -> Option<&Value> {
self.get(name)
}
}
Expand Down
10 changes: 5 additions & 5 deletions partiql-catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub type BaseTableExprResult<'a> =
pub trait BaseTableExpr: Debug {
fn evaluate<'c>(
&self,
args: &[Cow<Value>],
args: &[Cow<'_, Value>],
ctx: &'c dyn SessionContext<'c>,
) -> BaseTableExprResult<'c>;
}
Expand Down Expand Up @@ -117,9 +117,9 @@ pub enum CatalogErrorKind {
pub trait Catalog: Debug {
fn add_table_function(&mut self, info: TableFunction) -> Result<ObjectId, CatalogError>;

fn add_type_entry(&mut self, entry: TypeEnvEntry) -> Result<ObjectId, CatalogError>;
fn add_type_entry(&mut self, entry: TypeEnvEntry<'_>) -> Result<ObjectId, CatalogError>;

fn get_function(&self, name: &str) -> Option<FunctionEntry>;
fn get_function(&self, name: &str) -> Option<FunctionEntry<'_>>;

fn resolve_type(&self, name: &str) -> Option<TypeEntry>;
}
Expand Down Expand Up @@ -227,7 +227,7 @@ impl Catalog for PartiqlCatalog {
}
}

fn add_type_entry(&mut self, entry: TypeEnvEntry) -> Result<ObjectId, CatalogError> {
fn add_type_entry(&mut self, entry: TypeEnvEntry<'_>) -> Result<ObjectId, CatalogError> {
let id = self
.types
.add(entry.name.as_ref(), entry.aliases.as_slice(), entry.ty);
Expand All @@ -241,7 +241,7 @@ impl Catalog for PartiqlCatalog {
}
}

fn get_function(&self, name: &str) -> Option<FunctionEntry> {
fn get_function(&self, name: &str) -> Option<FunctionEntry<'_>> {
self.functions
.find_by_name(name)
.map(|(eid, entry)| FunctionEntry {
Expand Down
2 changes: 1 addition & 1 deletion partiql-conformance-tests/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub(crate) fn parse(statement: &str) -> ParserResult {
#[inline]
pub(crate) fn lower(
catalog: &dyn Catalog,
parsed: &Parsed,
parsed: &Parsed<'_>,
) -> Result<logical::LogicalPlan<logical::BindingsOp>, AstTransformationError> {
let planner = partiql_logical_planner::LogicalPlanner::new(catalog);
planner.lower(parsed)
Expand Down
2 changes: 1 addition & 1 deletion partiql-eval/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub mod basic {
T: Debug,
{
#[inline]
fn get(&self, name: &BindingsName) -> Option<&T> {
fn get(&self, name: &BindingsName<'_>) -> Option<&T> {
let idx = match name {
BindingsName::CaseSensitive(s) => self.sensitive.get(s.as_ref()),
BindingsName::CaseInsensitive(s) => {
Expand Down
2 changes: 1 addition & 1 deletion partiql-eval/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Evaluable for ErrorNode {
panic!("ErrorNode will not be evaluated")
}

fn update_input(&mut self, _input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, _input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
panic!("ErrorNode will not be evaluated")
}
}
Expand Down
4 changes: 2 additions & 2 deletions partiql-eval/src/eval/eval_expr_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ impl<const STRICT: bool, const N: usize, E: ExecuteEvalExpr<N>, ArgC: ArgChecker
}

/// Evaluate the input argument expressions in [`self.args`] in the environment, type check them,
/// and convert them into an array of `N` `Cow<Value>`s.
/// and convert them into an array of `N` `Cow<'_, Value>`s.
///
/// If type-checking fails, the appropriate failure case of [`ArgCheckControlFlow`] is returned,
/// else [`ArgCheckControlFlow::Continue`] is returned containing the `N` values.
pub fn evaluate_args<'a, 'c>(
&'a self,
bindings: &'a Tuple,
ctx: &'c dyn EvalContext<'c>,
) -> ControlFlow<Value, [Cow<Value>; N]>
) -> ControlFlow<Value, [Cow<'_, Value>; N]>
where
'c: 'a,
{
Expand Down
40 changes: 20 additions & 20 deletions partiql-eval/src/eval/evaluable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum EvalType {
/// `Evaluable` represents each evaluation operator in the evaluation plan as an evaluable entity.
pub trait Evaluable: Debug {
fn evaluate<'c>(&mut self, ctx: &'c dyn EvalContext<'c>) -> Value;
fn update_input(&mut self, input: Value, branch_num: u8, ctx: &dyn EvalContext);
fn update_input(&mut self, input: Value, branch_num: u8, ctx: &dyn EvalContext<'_>);
fn get_vars(&self) -> Option<&[String]> {
None
}
Expand Down Expand Up @@ -140,7 +140,7 @@ impl Evaluable for EvalScan {
Value::Bag(Box::new(value))
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}

Expand Down Expand Up @@ -337,7 +337,7 @@ impl Evaluable for EvalJoin {
Value::Bag(Box::new(output_bag))
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}

Expand Down Expand Up @@ -744,7 +744,7 @@ impl Evaluable for EvalGroupBy {
}
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -789,7 +789,7 @@ impl Evaluable for EvalPivot {
Value::from(tuple)
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -847,7 +847,7 @@ impl Evaluable for EvalUnpivot {
Value::from(unpivoted)
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}

Expand Down Expand Up @@ -894,7 +894,7 @@ impl Evaluable for EvalFilter {
Value::from(filtered.collect::<Bag>())
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -939,7 +939,7 @@ impl Evaluable for EvalHaving {
Value::from(filtered.collect::<Bag>())
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -1013,7 +1013,7 @@ impl Evaluable for EvalOrderBy {
Value::from(List::from(values))
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -1075,7 +1075,7 @@ impl Evaluable for EvalLimitOffset {
}
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -1112,7 +1112,7 @@ impl Evaluable for EvalSelectValue {
}
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -1173,7 +1173,7 @@ impl Evaluable for EvalSelect {
}
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -1210,7 +1210,7 @@ impl Evaluable for EvalSelectAll {
}
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand All @@ -1237,7 +1237,7 @@ impl Evaluable for EvalExprQuery {
self.expr.evaluate(&input_value, ctx).into_owned()
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -1266,7 +1266,7 @@ impl Evaluable for EvalDistinct {
}
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand All @@ -1281,7 +1281,7 @@ impl Evaluable for EvalSink {
self.input.take().unwrap_or_else(|| Missing)
}

fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) {
self.input = Some(input);
}
}
Expand Down Expand Up @@ -1318,7 +1318,7 @@ impl EvalExpr for EvalSubQueryExpr {
{
let bindings = MapBindings::from(bindings);
let value = {
let nested_ctx: NestedContext = NestedContext::new(bindings, ctx);
let nested_ctx: NestedContext<'_, '_> = NestedContext::new(bindings, ctx);

let mut plan = self.plan.borrow_mut();
if let Ok(evaluated) = plan.execute_mut(&nested_ctx) {
Expand Down Expand Up @@ -1377,7 +1377,7 @@ impl Evaluable for EvalOuterUnion {
Value::from(Bag::from(vals))
}

fn update_input(&mut self, input: Value, branch_num: u8, ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, branch_num: u8, ctx: &dyn EvalContext<'_>) {
match branch_num {
0 => self.l_input = Some(input),
1 => self.r_input = Some(input),
Expand Down Expand Up @@ -1433,7 +1433,7 @@ impl Evaluable for EvalOuterIntersect {
Value::from(bag)
}

fn update_input(&mut self, input: Value, branch_num: u8, ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, branch_num: u8, ctx: &dyn EvalContext<'_>) {
match branch_num {
0 => self.l_input = Some(input),
1 => self.r_input = Some(input),
Expand Down Expand Up @@ -1482,7 +1482,7 @@ impl Evaluable for EvalOuterExcept {
Value::from(Bag::from(vals))
}

fn update_input(&mut self, input: Value, branch_num: u8, ctx: &dyn EvalContext) {
fn update_input(&mut self, input: Value, branch_num: u8, ctx: &dyn EvalContext<'_>) {
match branch_num {
0 => self.l_input = Some(input),
1 => self.r_input = Some(input),
Expand Down
2 changes: 1 addition & 1 deletion partiql-eval/src/eval/expr/coll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl BindEvalExpr for EvalCollFn {
f: F,
) -> Result<Box<dyn EvalExpr>, BindError>
where
F: Fn(ValueIter) -> Value + 'static,
F: Fn(ValueIter<'_>) -> Value + 'static,
{
UnaryValueExpr::create_typed::<{ STRICT }, _>(types, args, move |value| {
value.sequence_iter().map(&f).unwrap_or(Missing)
Expand Down
4 changes: 2 additions & 2 deletions partiql-eval/src/eval/expr/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn as_str(v: &Value) -> Option<&str> {
}

#[inline]
fn as_name(v: &Value) -> Option<BindingsName> {
fn as_name(v: &Value) -> Option<BindingsName<'_>> {
as_str(v).map(|key| BindingsName::CaseInsensitive(Cow::Borrowed(key)))
}

Expand Down Expand Up @@ -189,7 +189,7 @@ impl BindEvalExpr for EvalVarRef {
}

#[inline]
fn borrow_or_missing(value: Option<&Value>) -> Cow<Value> {
fn borrow_or_missing(value: Option<&Value>) -> Cow<'_, Value> {
value.map_or_else(|| Cow::Owned(Missing), Cow::Borrowed)
}

Expand Down
4 changes: 2 additions & 2 deletions partiql-logical-planner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<'c> LogicalPlanner<'c> {
#[inline]
pub fn lower(
&self,
parsed: &Parsed,
parsed: &Parsed<'_>,
) -> Result<logical::LogicalPlan<logical::BindingsOp>, AstTransformationError> {
let q = &parsed.ast;
let catalog = PartiqlCatalog::default();
Expand Down Expand Up @@ -65,7 +65,7 @@ mod tests {

#[track_caller]
fn lower(
parsed: &Parsed,
parsed: &Parsed<'_>,
) -> Result<logical::LogicalPlan<logical::BindingsOp>, AstTransformationError> {
let catalog = PartiqlCatalog::default();
let planner = LogicalPlanner::new(&catalog);
Expand Down
4 changes: 2 additions & 2 deletions partiql-logical-planner/src/typer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl<'c> PlanTyper<'c> {
}

fn type_vexpr(&mut self, v: &ValueExpr, lookup_order: LookupOrder) {
fn binding_to_sym(binding: &BindingsName) -> SymbolPrimitive {
fn binding_to_sym(binding: &BindingsName<'_>) -> SymbolPrimitive {
match binding {
BindingsName::CaseSensitive(s) => SymbolPrimitive {
value: s.to_string(),
Expand Down Expand Up @@ -916,7 +916,7 @@ mod tests {

#[track_caller]
fn lower(
parsed: &Parsed,
parsed: &Parsed<'_>,
catalog: &dyn Catalog,
) -> Result<logical::LogicalPlan<logical::BindingsOp>, AstTransformationError> {
let planner = LogicalPlanner::new(catalog);
Expand Down
Loading

0 comments on commit f9c7bba

Please sign in to comment.