diff --git a/prqlc/prqlc/src/parser.rs b/prqlc/prqlc/src/parser.rs index 4f612b7348ad..4e690f7b1289 100644 --- a/prqlc/prqlc/src/parser.rs +++ b/prqlc/prqlc/src/parser.rs @@ -177,7 +177,7 @@ fn insert_stmts_at_path(module: &mut pr::ModuleDef, mut path: Vec, stmts } pub(crate) fn is_mod_def_for(stmt: &pr::Stmt, name: &str) -> bool { - stmt.kind.as_module_def().map_or(false, |x| x.name == name) + stmt.kind.as_module_def().is_some_and(|x| x.name == name) } fn path_starts_with_uppercase(p: &&PathBuf) -> bool { @@ -185,7 +185,7 @@ fn path_starts_with_uppercase(p: &&PathBuf) -> bool { .next() .and_then(|x| x.as_os_str().to_str()) .and_then(|x| x.chars().next()) - .map_or(false, |x| x.is_uppercase()) + .is_some_and(|x| x.is_uppercase()) } pub fn os_path_to_prql_path(path: &Path) -> Result> { diff --git a/prqlc/prqlc/src/semantic/lowering.rs b/prqlc/prqlc/src/semantic/lowering.rs index c37b823a95f5..487942ba2385 100644 --- a/prqlc/prqlc/src/semantic/lowering.rs +++ b/prqlc/prqlc/src/semantic/lowering.rs @@ -682,7 +682,7 @@ impl Lowerer { fn declare_as_columns(&mut self, exprs: pl::Expr, is_aggregation: bool) -> Result> { // special case: reference to a tuple that is a relational input - if exprs.ty.as_ref().map_or(false, |x| x.kind.is_tuple()) && exprs.kind.is_ident() { + if exprs.ty.as_ref().is_some_and(|x| x.kind.is_tuple()) && exprs.kind.is_ident() { // return all contained columns let input_id = exprs.target_id.as_ref().unwrap(); let id_mapping = self.node_mapping.get(input_id).unwrap(); @@ -741,7 +741,7 @@ impl Lowerer { let id = e.target_id.unwrap(); match e.kind { - pl::ExprKind::Ident(_) if e.ty.as_ref().map_or(false, |x| x.kind.is_tuple()) => { + pl::ExprKind::Ident(_) if e.ty.as_ref().is_some_and(|x| x.kind.is_tuple()) => { res.extend(self.find_selected_all(e, None).with_span(except.span)?); } pl::ExprKind::Ident(ident) => { @@ -835,7 +835,7 @@ impl Lowerer { pl::ExprKind::Ident(ident) => { log::debug!("lowering ident {ident} (target {:?})", expr.target_id); - if expr.ty.as_ref().map_or(false, |x| x.kind.is_tuple()) { + if expr.ty.as_ref().is_some_and(|x| x.kind.is_tuple()) { // special case: tuple ref let expr = pl::Expr { kind: pl::ExprKind::Ident(ident), diff --git a/prqlc/prqlc/src/semantic/mod.rs b/prqlc/prqlc/src/semantic/mod.rs index b0c1a0a27fe7..5446e9a3f038 100644 --- a/prqlc/prqlc/src/semantic/mod.rs +++ b/prqlc/prqlc/src/semantic/mod.rs @@ -86,7 +86,7 @@ pub fn is_ident_or_func_call(expr: &pl::Expr, name: &pr::Ident) -> bool { match &expr.kind { pl::ExprKind::Ident(i) if i == name => true, pl::ExprKind::FuncCall(pl::FuncCall { name: n_expr, .. }) - if n_expr.kind.as_ident().map_or(false, |i| i == name) => + if n_expr.kind.as_ident() == Some(name) => { true } diff --git a/prqlc/prqlc/src/semantic/resolver/expr.rs b/prqlc/prqlc/src/semantic/resolver/expr.rs index b48ac36c8844..5f1741b0dfab 100644 --- a/prqlc/prqlc/src/semantic/resolver/expr.rs +++ b/prqlc/prqlc/src/semantic/resolver/expr.rs @@ -150,7 +150,7 @@ impl pl::PlFold for Resolver<'_> { } pl::ExprKind::FuncCall(pl::FuncCall { name, args, .. }) - if (name.kind.as_ident()).map_or(false, |i| i.to_string() == "std.not") + if (name.kind.as_ident()).is_some_and(|i| i.to_string() == "std.not") && matches!(args[0].kind, pl::ExprKind::Tuple(_)) => { let arg = args.into_iter().exactly_one().unwrap(); diff --git a/prqlc/prqlc/src/semantic/resolver/stmt.rs b/prqlc/prqlc/src/semantic/resolver/stmt.rs index 35b493207069..c5aea1fa7a1d 100644 --- a/prqlc/prqlc/src/semantic/resolver/stmt.rs +++ b/prqlc/prqlc/src/semantic/resolver/stmt.rs @@ -109,7 +109,7 @@ impl super::Resolver<'_> { // var value is not provided // is this a relation? - if expected_ty.as_ref().map_or(false, |t| t.is_relation()) { + if expected_ty.as_ref().is_some_and(|t| t.is_relation()) { // treat this var as a TableDecl DeclKind::TableDecl(TableDecl { ty: expected_ty, diff --git a/prqlc/prqlc/src/semantic/resolver/transforms.rs b/prqlc/prqlc/src/semantic/resolver/transforms.rs index d8feb8a70f59..423fe34548e9 100644 --- a/prqlc/prqlc/src/semantic/resolver/transforms.rs +++ b/prqlc/prqlc/src/semantic/resolver/transforms.rs @@ -251,7 +251,7 @@ impl Resolver<'_> { let [pattern, value] = unpack::<2>(func.args); - if pattern.ty.as_ref().map_or(false, |x| x.kind.is_array()) { + if pattern.ty.as_ref().is_some_and(|x| x.kind.is_array()) { return Ok(Expr::new(ExprKind::RqOperator { name: "std.array_in".to_string(), args: vec![value, pattern], @@ -465,7 +465,7 @@ impl Resolver<'_> { /// Wraps non-tuple Exprs into a singleton Tuple. pub(super) fn coerce_into_tuple(&mut self, expr: Expr) -> Result { let is_tuple_ty = - expr.ty.as_ref().map_or(false, |t| t.kind.is_tuple()) && !expr.kind.is_all(); + expr.ty.as_ref().is_some_and(|t| t.kind.is_tuple()) && !expr.kind.is_all(); Ok(if is_tuple_ty { // a helpful check for a common anti-pattern if let Some(alias) = expr.alias { @@ -892,7 +892,7 @@ impl Lineage { } // special case: include a tuple - if expr.ty.as_ref().map_or(false, |x| x.kind.is_tuple()) && expr.kind.is_ident() { + if expr.ty.as_ref().is_some_and(|x| x.kind.is_tuple()) && expr.kind.is_ident() { // this ident is a tuple, which means it much point to an input let input_id = expr.target_id.unwrap(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5d865004fbe6..35f0e51acab3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,6 +1,6 @@ [toolchain] # Generally run 1 behind latest -channel = "1.83.0" +channel = "1.84.1" components = ["rustfmt", "clippy"] # We want two targets: wasm32, and the default target for the platform, which we # don't list here. (i.e. we use each platform to test each platform)