From fd0a29472235db290a007645abc15ec6003fe003 Mon Sep 17 00:00:00 2001 From: Vlamonster Date: Mon, 30 Oct 2023 01:37:25 +0100 Subject: [PATCH] Resolve lots of Clippy warnings. --- compiler/src/interpreter/x86var.rs | 18 +++++++-------- compiler/src/passes/atomize/atomize.rs | 8 ++----- compiler/src/passes/atomize/mod.rs | 2 +- compiler/src/passes/emit/mod.rs | 4 ++-- compiler/src/passes/explicate/explicate.rs | 1 + compiler/src/passes/explicate/interpret.rs | 23 ++++++++++--------- .../src/passes/interference/assign_homes.rs | 6 +---- .../interference/coloring_interference.rs | 2 ++ .../interference/compute_interference.rs | 1 + .../passes/interference/liveness_analysis.rs | 5 ++-- compiler/src/passes/parse/grammar.lalrpop | 6 ++--- compiler/src/passes/parse/grammar.rs | 6 ++--- compiler/src/passes/parse/interpreter.rs | 5 +--- compiler/src/passes/parse/mod.rs | 22 ++++++++++-------- .../patch_instructions/patch_instructions.rs | 6 +---- compiler/src/passes/reveal_functions/mod.rs | 4 ++-- .../reveal_functions/reveal_functions.rs | 3 ++- compiler/src/passes/select/io.rs | 2 +- compiler/src/passes/select/mod.rs | 11 +++------ compiler/src/passes/type_check/check.rs | 22 ++++++++---------- compiler/src/passes/uniquify/uniquify.rs | 3 ++- compiler/src/utils/split_test.rs | 1 + 22 files changed, 75 insertions(+), 86 deletions(-) diff --git a/compiler/src/interpreter/x86var.rs b/compiler/src/interpreter/x86var.rs index 5f6df92..98c719e 100644 --- a/compiler/src/interpreter/x86var.rs +++ b/compiler/src/interpreter/x86var.rs @@ -72,7 +72,7 @@ impl<'p> X86Concluded<'p> { block_ids, read_buffer: Vec::new(), write_buffer: Vec::new(), - status: Default::default(), + status: Status::default(), stats: IStats::default(), }; @@ -135,10 +135,10 @@ impl<'p, I: IO> X86Interpreter<'p, I> { self.stats.instructions_executed += 1; match instr { Instr::Addq { src, dst } => { - self.set_arg(dst, self.get_arg(src) + self.get_arg(dst)) + self.set_arg(dst, self.get_arg(src) + self.get_arg(dst)); } Instr::Subq { src, dst } => { - self.set_arg(dst, self.get_arg(dst) - self.get_arg(src)) + self.set_arg(dst, self.get_arg(dst) - self.get_arg(src)); } Instr::Negq { dst } => self.set_arg(dst, -self.get_arg(dst)), Instr::Movq { src, dst } => self.set_arg(dst, self.get_arg(src)), @@ -181,8 +181,8 @@ impl<'p, I: IO> X86Interpreter<'p, I> { Instr::Divq { divisor } => { let rax = self.regs[&Reg::RAX]; let rdx = self.regs[&Reg::RDX]; - let dividend = ((rdx as i128) << 64) | rax as i128; - let divisor = self.get_arg(divisor) as i128; + let dividend = (i128::from(rdx) << 64) | i128::from(rax); + let divisor = i128::from(self.get_arg(divisor)); self.regs.insert(Reg::RAX, (dividend / divisor) as i64); self.regs.insert(Reg::RDX, (dividend % divisor) as i64); @@ -226,16 +226,16 @@ impl<'p, I: IO> X86Interpreter<'p, I> { } } Instr::Andq { src, dst } => { - self.set_arg(dst, self.get_arg(src) & self.get_arg(dst)) + self.set_arg(dst, self.get_arg(src) & self.get_arg(dst)); } Instr::Orq { src, dst } => self.set_arg(dst, self.get_arg(src) | self.get_arg(dst)), Instr::Xorq { src, dst } => { - self.set_arg(dst, self.get_arg(src) ^ self.get_arg(dst)) + self.set_arg(dst, self.get_arg(src) ^ self.get_arg(dst)); } Instr::Notq { dst } => self.set_arg(dst, !self.get_arg(dst)), Instr::Setcc { cnd } => { let rax = self.regs[&Reg::RAX]; - let cnd = self.evaluate_cnd(*cnd) as i64; + let cnd = i64::from(self.evaluate_cnd(*cnd)); self.regs.insert(Reg::RAX, rax & !0xFF | cnd); } Instr::LoadLbl { sym, dst } => { @@ -288,7 +288,7 @@ impl<'p, I: IO> X86Interpreter<'p, I> { Cnd::LE => self.status.zero || self.status.sign != self.status.overflow, Cnd::NE => !self.status.zero, Cnd::NotOverflow => !self.status.overflow, - Cnd::NotSign => self.status.sign, + Cnd::NotSign => !self.status.sign, Cnd::Overflow => self.status.overflow, Cnd::ParityEven => self.status.parity_even, Cnd::ParityOdd => !self.status.parity_even, diff --git a/compiler/src/passes/atomize/atomize.rs b/compiler/src/passes/atomize/atomize.rs index 427784a..ce9cd7c 100644 --- a/compiler/src/passes/atomize/atomize.rs +++ b/compiler/src/passes/atomize/atomize.rs @@ -1,5 +1,5 @@ use crate::passes::atomize::{AExpr, Atom, PrgAtomized}; -use crate::passes::parse::{Def, Lit}; +use crate::passes::parse::Def; use crate::passes::reveal_functions::{PrgRevealed, RExpr}; use crate::utils::gen_sym::{gen_sym, UniqueSym}; @@ -89,11 +89,7 @@ fn atomize_expr(expr: RExpr) -> AExpr { bdy: Box::new(atomize_expr(*bdy)), }, RExpr::Break { bdy } => AExpr::Break { - bdy: bdy - .map(|bdy| Box::new(atomize_expr(*bdy))) - .unwrap_or(Box::new(AExpr::Atom { - atm: Atom::Val { val: Lit::Unit }, - })), + bdy: Box::new(atomize_expr(*bdy)), }, RExpr::Seq { stmt, cnt } => AExpr::Seq { stmt: Box::new(atomize_expr(*stmt)), diff --git a/compiler/src/passes/atomize/mod.rs b/compiler/src/passes/atomize/mod.rs index 1d7d117..d1ba761 100644 --- a/compiler/src/passes/atomize/mod.rs +++ b/compiler/src/passes/atomize/mod.rs @@ -119,7 +119,7 @@ impl<'p> From> for Expr> { bdy: Box::new((*bdy).into()), }, AExpr::Break { bdy } => Expr::Break { - bdy: Some(Box::new((*bdy).into())), + bdy: Box::new((*bdy).into()), }, AExpr::Seq { stmt, cnt } => Expr::Seq { stmt: Box::new((*stmt).into()), diff --git a/compiler/src/passes/emit/mod.rs b/compiler/src/passes/emit/mod.rs index 18587ea..b1555b7 100644 --- a/compiler/src/passes/emit/mod.rs +++ b/compiler/src/passes/emit/mod.rs @@ -89,7 +89,7 @@ fn emit_instr<'p>( } Instr::Jcc { lbl, cnd } => { rel_jumps.insert(machine_code.len() + 2, *lbl); - vec![0x0F, encode_cnd(cnd), 0x00, 0x00, 0x00, 0x00] + vec![0x0F, encode_cnd(*cnd), 0x00, 0x00, 0x00, 0x00] } Instr::Retq => vec![0xC3], Instr::Syscall { .. } => vec![0x0F, 0x05], @@ -137,7 +137,7 @@ fn encode_reg(reg: &Reg) -> (u8, u8) { } } -fn encode_cnd(cnd: &Cnd) -> u8 { +fn encode_cnd(cnd: Cnd) -> u8 { match cnd { Cnd::Above => 0x87, Cnd::AboveOrEqual | Cnd::NotCarry => 0x83, diff --git a/compiler/src/passes/explicate/explicate.rs b/compiler/src/passes/explicate/explicate.rs index fc9c3bf..c0dd7be 100644 --- a/compiler/src/passes/explicate/explicate.rs +++ b/compiler/src/passes/explicate/explicate.rs @@ -11,6 +11,7 @@ struct Env<'a, 'p> { } impl<'p> PrgAtomized<'p> { + #[must_use] pub fn explicate(self) -> PrgExplicated<'p> { let mut blocks = HashMap::new(); let mut env = Env { diff --git a/compiler/src/passes/explicate/interpret.rs b/compiler/src/passes/explicate/interpret.rs index aee545a..8914ee5 100644 --- a/compiler/src/passes/explicate/interpret.rs +++ b/compiler/src/passes/explicate/interpret.rs @@ -34,17 +34,6 @@ impl<'p> PrgExplicated<'p> { } } - pub fn interpret_atom( - &self, - atom: &Atom<'p>, - scope: &PushMap, Val>>, - ) -> Val> { - match atom { - Atom::Val { val } => (*val).into(), - Atom::Var { sym } => scope[sym], - } - } - pub fn interpret_expr( &self, expr: &CExpr<'p>, @@ -159,4 +148,16 @@ impl<'p> PrgExplicated<'p> { } } } + + #[must_use] + pub fn interpret_atom( + &self, + atom: &Atom<'p>, + scope: &PushMap, Val>>, + ) -> Val> { + match atom { + Atom::Val { val } => (*val).into(), + Atom::Var { sym } => scope[sym], + } + } } diff --git a/compiler/src/passes/interference/assign_homes.rs b/compiler/src/passes/interference/assign_homes.rs index b7490cf..6e8592c 100644 --- a/compiler/src/passes/interference/assign_homes.rs +++ b/compiler/src/passes/interference/assign_homes.rs @@ -1,7 +1,3 @@ -//! This pass compiles `X86VarProgram`s into `AX86Program`. -//! -//! This pass is responsible for assigning all the program variables to locations on the stack. - use crate::language::x86var::{Arg, Block, Instr, VarArg, X86Assigned, X86Colored}; use crate::utils::gen_sym::UniqueSym; use crate::{ @@ -11,7 +7,7 @@ use crate::{ use std::collections::HashMap; impl<'p> X86Colored<'p> { - /// See module-level documentation. + #[must_use] pub fn assign_homes(self) -> X86Assigned<'p> { X86Assigned { blocks: self diff --git a/compiler/src/passes/interference/coloring_interference.rs b/compiler/src/passes/interference/coloring_interference.rs index f3e74a4..db71854 100644 --- a/compiler/src/passes/interference/coloring_interference.rs +++ b/compiler/src/passes/interference/coloring_interference.rs @@ -4,6 +4,7 @@ use itertools::Itertools; use std::collections::{HashMap, HashSet}; impl<'p> X86WithInterference<'p> { + #[must_use] pub fn color_interference(self) -> X86Colored<'p> { let (color_map, stack_space) = color_graph(self.interference); @@ -17,6 +18,7 @@ impl<'p> X86WithInterference<'p> { } } +#[must_use] fn color_graph(graph: InterferenceGraph) -> (HashMap, usize) { let mut queue = Vec::new(); let mut node_map = HashMap::::new(); diff --git a/compiler/src/passes/interference/compute_interference.rs b/compiler/src/passes/interference/compute_interference.rs index 0e069a3..e3bbcf6 100644 --- a/compiler/src/passes/interference/compute_interference.rs +++ b/compiler/src/passes/interference/compute_interference.rs @@ -5,6 +5,7 @@ use crate::passes::interference::liveness_analysis::{handle_instr, ReadWriteOp}; use std::collections::HashMap; impl<'p> LX86VarProgram<'p> { + #[must_use] pub fn compute_interference(self) -> X86WithInterference<'p> { X86WithInterference { interference: self.build_graph(), diff --git a/compiler/src/passes/interference/liveness_analysis.rs b/compiler/src/passes/interference/liveness_analysis.rs index 2d0edd1..760527d 100644 --- a/compiler/src/passes/interference/liveness_analysis.rs +++ b/compiler/src/passes/interference/liveness_analysis.rs @@ -8,6 +8,7 @@ use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; impl<'p> X86Selected<'p> { + #[must_use] pub fn add_liveness(self) -> LX86VarProgram<'p> { // let graph = create_graph(&self.blocks); @@ -40,12 +41,12 @@ impl<'p> X86Selected<'p> { match liveness.get(sym) { None => { liveness.insert(*sym, new_liveness); - changed = true + changed = true; } Some(old_liveness) => { if *old_liveness != new_liveness { liveness.insert(*sym, new_liveness); - changed = true + changed = true; } } } diff --git a/compiler/src/passes/parse/grammar.lalrpop b/compiler/src/passes/parse/grammar.lalrpop index e4125ad..5e200f7 100644 --- a/compiler/src/passes/parse/grammar.lalrpop +++ b/compiler/src/passes/parse/grammar.lalrpop @@ -1,5 +1,5 @@ use std::str::FromStr; -use crate::passes::parse::*; +use crate::passes::parse::{Def, Expr, Lit, Op, Param} use crate::passes::parse::PrgParsed; use crate::passes::type_check::Type; @@ -164,13 +164,13 @@ ExprInStmt: Expr<&'input str> = { cnd: Box::new(cnd), thn: Box::new(bdy), els: Box::new(Expr::Seq { - stmt: Box::new(Expr::Break { bdy: None }), + stmt: Box::new(Expr::Break { bdy: Box::new(Expr::Lit { val: Lit::Unit }) }), cnt: Box::new(Expr::Lit { val: Lit::Unit }), }), }), }, "break" => Expr::Break { - bdy: bdy.map(Box::new), + bdy: Box::new(bdy.unwrap_or(Expr::Lit { val: Lit::Unit })), }, ExprLogicalOr, } diff --git a/compiler/src/passes/parse/grammar.rs b/compiler/src/passes/parse/grammar.rs index eef1359..977ed43 100644 --- a/compiler/src/passes/parse/grammar.rs +++ b/compiler/src/passes/parse/grammar.rs @@ -1,5 +1,5 @@ // auto-generated: "lalrpop 0.20.1" -// sha3: 19eaac2958ee7627671379b88ee4fd1bbd2700d0b51bbf42e8cfb929dab502b9 +// sha3: c9e9fedb1e07d89e4fbaef0611beb45686afea48b8df51c64ffcd5ddf109995e use std::str::FromStr; use crate::passes::parse::*; use crate::passes::parse::PrgParsed; @@ -4597,7 +4597,7 @@ fn __action18< cnd: Box::new(cnd), thn: Box::new(bdy), els: Box::new(Expr::Seq { - stmt: Box::new(Expr::Break { bdy: None }), + stmt: Box::new(Expr::Break { bdy: Box::new(Expr::Lit { val: Lit::Unit }) }), cnt: Box::new(Expr::Lit { val: Lit::Unit }), }), }), @@ -4615,7 +4615,7 @@ fn __action19< ) -> Expr<&'input str> { Expr::Break { - bdy: bdy.map(Box::new), + bdy: Box::new(bdy.unwrap_or(Expr::Lit { val: Lit::Unit })), } } diff --git a/compiler/src/passes/parse/interpreter.rs b/compiler/src/passes/parse/interpreter.rs index 15fd83b..3073be7 100644 --- a/compiler/src/passes/parse/interpreter.rs +++ b/compiler/src/passes/parse/interpreter.rs @@ -184,10 +184,7 @@ impl PrgGenericVar { } }, Expr::Break { bdy } => { - return ControlFlow::Break(match bdy { - Some(bdy) => b!(self.interpret_expr(bdy, scope, io)), - None => Val::Unit, - }) + return ControlFlow::Break(b!(self.interpret_expr(bdy, scope, io))) } Expr::Seq { stmt, cnt } => { b!(self.interpret_expr(stmt, scope, io)); diff --git a/compiler/src/passes/parse/mod.rs b/compiler/src/passes/parse/mod.rs index 043ae4b..8abe88e 100644 --- a/compiler/src/passes/parse/mod.rs +++ b/compiler/src/passes/parse/mod.rs @@ -1,5 +1,5 @@ #[rustfmt::skip] -#[allow(clippy::all)] +#[allow(clippy::all, clippy::pedantic)] mod grammar; pub mod interpreter; pub mod parse; @@ -69,7 +69,7 @@ pub enum Expr { bdy: Box>, }, Break { - bdy: Option>>, + bdy: Box>, }, Seq { stmt: Box>, @@ -113,17 +113,21 @@ pub enum Lit { } impl Lit { + #[must_use] pub fn int(self) -> i64 { - match self { - Lit::Int { val } => val, - _ => panic!(), + if let Lit::Int { val } = self { + val + } else { + panic!() } } + #[must_use] pub fn bool(self) -> bool { - match self { - Lit::Bool { val } => val, - _ => panic!(), + if let Lit::Bool { val } = self { + val + } else { + panic!() } } } @@ -134,7 +138,7 @@ mod tests { use test_each_file::test_each_file; fn parse([test]: [&str; 1]) { - split_test(test); + let _ = split_test(test); } test_each_file! { for ["test"] in "./programs/good" as parse => parse } diff --git a/compiler/src/passes/patch_instructions/patch_instructions.rs b/compiler/src/passes/patch_instructions/patch_instructions.rs index c08f627..24e573a 100644 --- a/compiler/src/passes/patch_instructions/patch_instructions.rs +++ b/compiler/src/passes/patch_instructions/patch_instructions.rs @@ -1,12 +1,8 @@ -//! This pass compiles `AX86Program`s into `PX86Program`. -//! -//! This pass makes sure that no instructions use more than one argument that is dereferenced. - use crate::language::x86var::{Arg, Block, Instr, X86Assigned, X86Patched}; use crate::{addq, movq, reg, subq}; impl<'p> X86Assigned<'p> { - /// See module-level documentation. + #[must_use] pub fn patch(self) -> X86Patched<'p> { X86Patched { blocks: self diff --git a/compiler/src/passes/reveal_functions/mod.rs b/compiler/src/passes/reveal_functions/mod.rs index 773d5d5..e62717c 100644 --- a/compiler/src/passes/reveal_functions/mod.rs +++ b/compiler/src/passes/reveal_functions/mod.rs @@ -44,7 +44,7 @@ pub enum RExpr<'p> { bdy: Box>, }, Break { - bdy: Option>>, + bdy: Box>, }, Seq { stmt: Box>, @@ -116,7 +116,7 @@ impl<'p> From> for Expr> { bdy: Box::new((*bdy).into()), }, RExpr::Break { bdy } => Expr::Break { - bdy: bdy.map(|bdy| Box::new((*bdy).into())), + bdy: Box::new((*bdy).into()), }, RExpr::Seq { stmt, cnt } => Expr::Seq { stmt: Box::new((*stmt).into()), diff --git a/compiler/src/passes/reveal_functions/reveal_functions.rs b/compiler/src/passes/reveal_functions/reveal_functions.rs index ee7e7f2..38bbdd4 100644 --- a/compiler/src/passes/reveal_functions/reveal_functions.rs +++ b/compiler/src/passes/reveal_functions/reveal_functions.rs @@ -5,6 +5,7 @@ use crate::utils::gen_sym::UniqueSym; use crate::utils::push_map::PushMap; impl<'p> PrgUniquified<'p> { + #[must_use] pub fn reveal(self) -> PrgRevealed<'p> { let mut scope = PushMap::from_iter(self.defs.keys().map(|s| (*s, ()))); @@ -76,7 +77,7 @@ fn reveal_expr<'p>(expr: Expr>, scope: &mut PushMap, bdy: Box::new(reveal_expr(*bdy, scope)), }, Expr::Break { bdy } => RExpr::Break { - bdy: bdy.map(|bdy| Box::new(reveal_expr(*bdy, scope))), + bdy: Box::new(reveal_expr(*bdy, scope)), }, Expr::Seq { stmt, cnt } => RExpr::Seq { stmt: Box::new(reveal_expr(*stmt, scope)), diff --git a/compiler/src/passes/select/io.rs b/compiler/src/passes/select/io.rs index 72af130..7710089 100644 --- a/compiler/src/passes/select/io.rs +++ b/compiler/src/passes/select/io.rs @@ -7,7 +7,7 @@ use crate::{ }; use std::collections::HashMap; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct Std<'p> { pub exit: UniqueSym<'p>, pub print_int: UniqueSym<'p>, diff --git a/compiler/src/passes/select/mod.rs b/compiler/src/passes/select/mod.rs index acdca92..14bb123 100644 --- a/compiler/src/passes/select/mod.rs +++ b/compiler/src/passes/select/mod.rs @@ -1,8 +1,3 @@ -//! This pass begins the work of translating from `CVarProgram` to `X86`. -//! The target language `X86VarProgram` of this pass is a variant of x86 that still uses variables. -//! -//! Just like a `CVarProgram` program, a `X86VarProgram` consists of a list of blocks. - pub mod io; use crate::language::x86var::{ @@ -17,7 +12,7 @@ use crate::*; use std::collections::HashMap; impl<'p> PrgExplicated<'p> { - /// See module-level documentation. + #[must_use] pub fn select(self) -> X86Selected<'p> { let mut blocks = HashMap::new(); let std = Std::new(&mut blocks); @@ -47,7 +42,7 @@ fn select_block<'p>( if let Some(params) = fn_params.get(&sym) { instrs.push(pushq!(reg!(RBP))); instrs.push(movq!(reg!(RSP), reg!(RBP))); - for reg in CALLEE_SAVED_NO_STACK.into_iter() { + for reg in CALLEE_SAVED_NO_STACK { instrs.push(pushq!(VarArg::Reg { reg })); } @@ -89,7 +84,7 @@ fn select_tail<'p>(tail: Tail<'p>, instrs: &mut Vec>>, std: cmpq!(select_atom(&args[1]), var!(tmp)), jcc!(thn, select_cmp(op)), jmp!(els), - ]) + ]); } _ => unreachable!(), }, diff --git a/compiler/src/passes/type_check/check.rs b/compiler/src/passes/type_check/check.rs index df6a8db..494dacb 100644 --- a/compiler/src/passes/type_check/check.rs +++ b/compiler/src/passes/type_check/check.rs @@ -1,7 +1,6 @@ use crate::passes::parse::{Def, Expr, Lit, Op, PrgParsed}; use crate::passes::type_check::check::TypeError::*; -use crate::passes::type_check::PrgTypeChecked; -use crate::passes::type_check::*; +use crate::passes::type_check::{PrgTypeChecked, Type}; use crate::utils::expect::expect; use crate::utils::push_map::PushMap; use miette::Diagnostic; @@ -94,7 +93,7 @@ impl<'p> PrgParsed<'p> { params.iter().map(|p| (p.sym, (p.mutable, p.typ.clone()))), |env| expect_type(bdy, typ.clone(), env), ) - .map(|_| (sym, def)), + .map(|()| (sym, def)), }) .collect::, _>>()?; @@ -126,7 +125,7 @@ fn uncover_fns<'p>(program: &PrgParsed<'p>) -> Result(program: &PrgParsed<'p>) -> Result(expr: &Expr<&'p str>, env: &mut Env<'_, 'p>) -> Result match (op, args.as_slice()) { (Op::Plus | Op::Minus | Op::Mul | Op::Mod | Op::Div, [e1, e2]) => { @@ -241,17 +240,14 @@ fn type_check_expr<'p>(expr: &Expr<&'p str>, env: &mut Env<'_, 'p>) -> Result { expect(env.in_loop, BreakOutsideLoop)?; - let bdy_type = match bdy { - None => Type::Unit, - Some(bdy) => type_check_expr(bdy, env)?, - }; + let bdy_type = type_check_expr(bdy, env)?; if let Some(loop_type) = env.loop_type { expect( *loop_type == bdy_type, TypeMismatchEqual { t1: loop_type.clone(), - t2: bdy_type.clone(), + t2: bdy_type, }, )?; } else { @@ -266,12 +262,12 @@ fn type_check_expr<'p>(expr: &Expr<&'p str>, env: &mut Env<'_, 'p>) -> Result { let (mutable, typ) = env.scope.get(sym).cloned().ok_or(UndeclaredVar { - sym: sym.to_string(), + sym: (*sym).to_string(), })?; expect( mutable, ModifyImmutable { - sym: sym.to_string(), + sym: (*sym).to_string(), }, )?; expect_type(bnd, typ, env)?; diff --git a/compiler/src/passes/uniquify/uniquify.rs b/compiler/src/passes/uniquify/uniquify.rs index bc5e823..87a1858 100644 --- a/compiler/src/passes/uniquify/uniquify.rs +++ b/compiler/src/passes/uniquify/uniquify.rs @@ -5,6 +5,7 @@ use crate::utils::gen_sym::{gen_sym, UniqueSym}; use crate::utils::push_map::PushMap; impl<'p> PrgTypeChecked<'p> { + #[must_use] pub fn uniquify(self) -> PrgUniquified<'p> { let mut scope = PushMap::from_iter(self.defs.iter().map(|(&sym, _)| (sym, gen_sym(sym)))); @@ -99,7 +100,7 @@ fn uniquify_expression<'p>( bdy: Box::new(uniquify_expression(*bdy, scope)), }, Expr::Break { bdy } => Expr::Break { - bdy: bdy.map(|bdy| Box::new(uniquify_expression(*bdy, scope))), + bdy: Box::new(uniquify_expression(*bdy, scope)), }, Expr::Seq { stmt, cnt } => Expr::Seq { stmt: Box::new(uniquify_expression(*stmt, scope)), diff --git a/compiler/src/utils/split_test.rs b/compiler/src/utils/split_test.rs index 4603565..b38033b 100644 --- a/compiler/src/utils/split_test.rs +++ b/compiler/src/utils/split_test.rs @@ -27,6 +27,7 @@ pub fn split_test_raw(test: &str) -> (Vec, Vec, Lit, &str) { (input, expected_output, expected_return, program) } +#[must_use] pub fn split_test(test: &str) -> (Vec, Vec, Lit, PrgParsed) { let (input, expected_output, expected_return, program) = split_test_raw(test); let program = parse_program(program).unwrap();