From f0c871711c11cb2aa5a249b3f4827be8078163d5 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 14 Sep 2025 19:08:59 -0400 Subject: [PATCH] compiler: updated to rust 1.84, now we have let chains! --- compiler/cl-ast/src/ast_impl/path.rs | 8 ++++---- compiler/cl-ast/src/desugar/constant_folder.rs | 12 ++++++------ compiler/cl-repl/examples/to_c.rs | 4 ++-- compiler/cl-repl/src/cli.rs | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/compiler/cl-ast/src/ast_impl/path.rs b/compiler/cl-ast/src/ast_impl/path.rs index 71ce211..2294d20 100644 --- a/compiler/cl-ast/src/ast_impl/path.rs +++ b/compiler/cl-ast/src/ast_impl/path.rs @@ -39,10 +39,10 @@ impl Path { /// Checks whether this path refers to the sinkhole identifier, `_` pub fn is_sinkhole(&self) -> bool { - if let [PathPart::Ident(id)] = self.parts.as_slice() { - if let "_" = id.to_ref() { - return true; - } + if let [PathPart::Ident(id)] = self.parts.as_slice() + && let "_" = id.to_ref() + { + return true; } false } diff --git a/compiler/cl-ast/src/desugar/constant_folder.rs b/compiler/cl-ast/src/desugar/constant_folder.rs index 27087fd..a1c0a59 100644 --- a/compiler/cl-ast/src/desugar/constant_folder.rs +++ b/compiler/cl-ast/src/desugar/constant_folder.rs @@ -62,12 +62,12 @@ impl Fold for ConstantFolder { (Div, |a, b| a / b, Int -> Int), (Rem, |a, b| a % b, Int -> Int), // Cursed bit-smuggled float shenanigans - (Lt, |a, b| (f64::from_bits(a) < f64::from_bits(b)), Float -> Bool), - (LtEq, |a, b| (f64::from_bits(a) >= f64::from_bits(b)), Float -> Bool), - (Equal, |a, b| (f64::from_bits(a) == f64::from_bits(b)), Float -> Bool), - (NotEq, |a, b| (f64::from_bits(a) != f64::from_bits(b)), Float -> Bool), - (GtEq, |a, b| (f64::from_bits(a) <= f64::from_bits(b)), Float -> Bool), - (Gt, |a, b| (f64::from_bits(a) > f64::from_bits(b)), Float -> Bool), + (Lt, |a, b| f64::from_bits(a) < f64::from_bits(b), Float -> Bool), + (LtEq, |a, b| f64::from_bits(a) >= f64::from_bits(b), Float -> Bool), + (Equal, |a, b| f64::from_bits(a) == f64::from_bits(b), Float -> Bool), + (NotEq, |a, b| f64::from_bits(a) != f64::from_bits(b), Float -> Bool), + (GtEq, |a, b| f64::from_bits(a) <= f64::from_bits(b), Float -> Bool), + (Gt, |a, b| f64::from_bits(a) > f64::from_bits(b), Float -> Bool), (Add, |a, b| (f64::from_bits(a) + f64::from_bits(b)).to_bits(), Float -> Float), (Sub, |a, b| (f64::from_bits(a) - f64::from_bits(b)).to_bits(), Float -> Float), (Mul, |a, b| (f64::from_bits(a) * f64::from_bits(b)).to_bits(), Float -> Float), diff --git a/compiler/cl-repl/examples/to_c.rs b/compiler/cl-repl/examples/to_c.rs index 9af863b..736383c 100644 --- a/compiler/cl-repl/examples/to_c.rs +++ b/compiler/cl-repl/examples/to_c.rs @@ -72,7 +72,7 @@ pub mod clangifier { Self::default() } - pub fn indent(&mut self) -> Section { + pub fn indent(&mut self) -> Section<'_> { Section::new(self) } @@ -104,7 +104,7 @@ pub mod clangifier { } /// Prints a section header and increases indentation - pub fn nest(&mut self, name: impl Display) -> Section { + pub fn nest(&mut self, name: impl Display) -> Section<'_> { print!("{name}"); self.indent() } diff --git a/compiler/cl-repl/src/cli.rs b/compiler/cl-repl/src/cli.rs index 36a8eb1..d177ad0 100644 --- a/compiler/cl-repl/src/cli.rs +++ b/compiler/cl-repl/src/cli.rs @@ -78,10 +78,10 @@ pub fn run(args: Args) -> Result<(), Box> { } if repl { - if let Some(file) = file { - if let Err(e) = load_file(&mut env, file) { - eprintln!("{e}") - } + if let Some(file) = file + && let Err(e) = load_file(&mut env, file) + { + eprintln!("{e}") } let mut ctx = Context::with_env(env); match mode { @@ -106,7 +106,7 @@ pub fn run(args: Args) -> Result<(), Box> { Ok(()) } -fn format_path_for_display(path: Option<&Path>) -> Cow { +fn format_path_for_display(path: Option<&Path>) -> Cow<'_, str> { match path { Some(file) => file .to_str()