Housekeeping with clippy

This commit is contained in:
Rerumu 2023-06-20 14:07:25 -04:00
parent 857737ff52
commit 7a49d61e0a
13 changed files with 96 additions and 117 deletions

View File

@ -105,18 +105,17 @@ impl DriverNoContext for BinOp {
write!(w, "(")?; write!(w, "(")?;
self.lhs().write(w)?; self.lhs().write(w)?;
write!(w, " {symbol} ")?; write!(w, " {symbol} ")?;
self.rhs().write(w)?;
write!(w, ")")
} else { } else {
let (head, tail) = self.op_type().as_name(); let (head, tail) = self.op_type().as_name();
write!(w, "{head}_{tail}(")?; write!(w, "{head}_{tail}(")?;
self.lhs().write(w)?; self.lhs().write(w)?;
write!(w, ", ")?; write!(w, ", ")?;
}
self.rhs().write(w)?; self.rhs().write(w)?;
write!(w, ")") write!(w, ")")
} }
}
} }
struct CmpOpBoolean<'a>(&'a CmpOp); struct CmpOpBoolean<'a>(&'a CmpOp);

View File

@ -65,7 +65,7 @@ impl Manager {
self.label_list.pop().unwrap(); self.label_list.pop().unwrap();
} }
pub fn indentation(&self) -> usize { pub const fn indentation(&self) -> usize {
self.indentation self.indentation
} }

View File

@ -25,11 +25,11 @@ trait AsIEName {
impl AsIEName for External { impl AsIEName for External {
fn as_ie_name(&self) -> &str { fn as_ie_name(&self) -> &str {
match self { match self {
External::Func => "func_list", Self::Func => "func_list",
External::Table => "table_list", Self::Table => "table_list",
External::Memory => "memory_list", Self::Memory => "memory_list",
External::Global => "global_list", Self::Global => "global_list",
External::Tag => unimplemented!(), Self::Tag => unimplemented!(),
} }
} }
} }
@ -41,10 +41,7 @@ fn reader_to_code(reader: OperatorsReader) -> Vec<Operator> {
} }
fn write_named_array(name: &str, len: usize, w: &mut dyn Write) -> Result<()> { fn write_named_array(name: &str, len: usize, w: &mut dyn Write) -> Result<()> {
let len = match len.checked_sub(1) { let Some(len) = len.checked_sub(1) else { return Ok(()) };
Some(len) => len,
None => return Ok(()),
};
writeln!(w, "local {name} = table_new({len}, 1)") writeln!(w, "local {name} = table_new({len}, 1)")
} }
@ -154,13 +151,7 @@ fn write_global_list(wasm: &Module, type_info: &TypeInfo, w: &mut dyn Write) ->
fn write_element_list(list: &[Element], type_info: &TypeInfo, w: &mut dyn Write) -> Result<()> { fn write_element_list(list: &[Element], type_info: &TypeInfo, w: &mut dyn Write) -> Result<()> {
for element in list { for element in list {
let (index, init) = match element.kind { let ElementKind::Active { table_index: index, offset_expr: init } = element.kind else { unreachable!() };
ElementKind::Active {
table_index,
offset_expr,
} => (table_index, offset_expr),
_ => unimplemented!(),
};
writeln!(w, "\tdo")?; writeln!(w, "\tdo")?;
writeln!(w, "\t\tlocal target = TABLE_LIST[{index}].data")?; writeln!(w, "\t\tlocal target = TABLE_LIST[{index}].data")?;
@ -264,10 +255,9 @@ fn write_localize_used(func_list: &[FuncData], w: &mut dyn Write) -> Result<BTre
fn write_func_start(wasm: &Module, index: u32, w: &mut dyn Write) -> Result<()> { fn write_func_start(wasm: &Module, index: u32, w: &mut dyn Write) -> Result<()> {
write!(w, "FUNC_LIST[{index}] = ")?; write!(w, "FUNC_LIST[{index}] = ")?;
match wasm.name_section().get(&index) { wasm.name_section()
Some(name) => write!(w, "--[[ {name} ]] "), .get(&index)
None => Ok(()), .map_or_else(|| Ok(()), |name| write!(w, "--[[ {name} ]] "))
}
} }
fn write_func_list(wasm: &Module, func_list: &[FuncData], w: &mut dyn Write) -> Result<()> { fn write_func_list(wasm: &Module, func_list: &[FuncData], w: &mut dyn Write) -> Result<()> {

View File

@ -125,18 +125,17 @@ impl DriverNoContext for BinOp {
write!(w, "(")?; write!(w, "(")?;
self.lhs().write(w)?; self.lhs().write(w)?;
write!(w, " {symbol} ")?; write!(w, " {symbol} ")?;
self.rhs().write(w)?;
write!(w, ")")
} else { } else {
let (head, tail) = self.op_type().as_name(); let (head, tail) = self.op_type().as_name();
write!(w, "{head}_{tail}(")?; write!(w, "{head}_{tail}(")?;
self.lhs().write(w)?; self.lhs().write(w)?;
write!(w, ", ")?; write!(w, ", ")?;
}
self.rhs().write(w)?; self.rhs().write(w)?;
write!(w, ")") write!(w, ")")
} }
}
} }
struct CmpOpBoolean<'a>(&'a CmpOp); struct CmpOpBoolean<'a>(&'a CmpOp);

View File

@ -61,7 +61,7 @@ impl Manager {
self.label_list.pop().unwrap(); self.label_list.pop().unwrap();
} }
pub fn indentation(&self) -> usize { pub const fn indentation(&self) -> usize {
self.indentation self.indentation
} }

View File

@ -27,7 +27,7 @@ impl Driver for Br {
} }
if self.target() == 0 { if self.target() == 0 {
if let Some(Some(LabelType::Backward)) = mng.label_list().last() { if mng.label_list().last() == Some(&Some(LabelType::Backward)) {
line!(mng, w, "continue") line!(mng, w, "continue")
} else { } else {
line!(mng, w, "break") line!(mng, w, "break")

View File

@ -25,11 +25,11 @@ trait AsIEName {
impl AsIEName for External { impl AsIEName for External {
fn as_ie_name(&self) -> &str { fn as_ie_name(&self) -> &str {
match self { match self {
External::Func => "func_list", Self::Func => "func_list",
External::Table => "table_list", Self::Table => "table_list",
External::Memory => "memory_list", Self::Memory => "memory_list",
External::Global => "global_list", Self::Global => "global_list",
External::Tag => unimplemented!(), Self::Tag => unimplemented!(),
} }
} }
} }
@ -41,10 +41,7 @@ fn reader_to_code(reader: OperatorsReader) -> Vec<Operator> {
} }
fn write_named_array(name: &str, len: usize, w: &mut dyn Write) -> Result<()> { fn write_named_array(name: &str, len: usize, w: &mut dyn Write) -> Result<()> {
let len = match len.checked_sub(1) { let Some(len) = len.checked_sub(1) else { return Ok(()) };
Some(len) => len,
None => return Ok(()),
};
writeln!(w, "local {name} = table.create({len})") writeln!(w, "local {name} = table.create({len})")
} }
@ -154,13 +151,7 @@ fn write_global_list(wasm: &Module, type_info: &TypeInfo, w: &mut dyn Write) ->
fn write_element_list(list: &[Element], type_info: &TypeInfo, w: &mut dyn Write) -> Result<()> { fn write_element_list(list: &[Element], type_info: &TypeInfo, w: &mut dyn Write) -> Result<()> {
for element in list { for element in list {
let (index, init) = match element.kind { let ElementKind::Active { table_index: index, offset_expr: init } = element.kind else { unreachable!() };
ElementKind::Active {
table_index,
offset_expr,
} => (table_index, offset_expr),
_ => unimplemented!(),
};
writeln!(w, "\tdo")?; writeln!(w, "\tdo")?;
writeln!(w, "\t\tlocal target = TABLE_LIST[{index}].data")?; writeln!(w, "\t\tlocal target = TABLE_LIST[{index}].data")?;
@ -277,10 +268,9 @@ fn write_localize_used(
fn write_func_start(wasm: &Module, index: u32, w: &mut dyn Write) -> Result<()> { fn write_func_start(wasm: &Module, index: u32, w: &mut dyn Write) -> Result<()> {
write!(w, "FUNC_LIST[{index}] = ")?; write!(w, "FUNC_LIST[{index}] = ")?;
match wasm.name_section().get(&index) { wasm.name_section()
Some(name) => write!(w, "--[[ {name} ]] "), .get(&index)
None => Ok(()), .map_or_else(|| Ok(()), |name| write!(w, "--[[ {name} ]] "))
}
} }
fn write_func_list(wasm: &Module, func_list: &[FuncData], w: &mut dyn Write) -> Result<()> { fn write_func_list(wasm: &Module, func_list: &[FuncData], w: &mut dyn Write) -> Result<()> {

View File

@ -25,8 +25,8 @@ impl Luau {
} }
fn write_i64(data: i64, w: &mut dyn Write) -> Result<()> { fn write_i64(data: i64, w: &mut dyn Write) -> Result<()> {
let data_1 = (data & 0xFFFFFFFF) as u32; let data_1 = (data & 0xFFFF_FFFF) as u32;
let data_2 = (data >> 32 & 0xFFFFFFFF) as u32; let data_2 = (data >> 32 & 0xFFFF_FFFF) as u32;
write!(w, "rt.i64.from_u32({data_1}, {data_2})") write!(w, "rt.i64.from_u32({data_1}, {data_2})")
} }

View File

@ -13,6 +13,7 @@ use wast::{
macro_rules! impl_write_number_nan { macro_rules! impl_write_number_nan {
($name:ident, $name_nan:ident, $numeric:ty, $pattern:ty) => { ($name:ident, $name_nan:ident, $numeric:ty, $pattern:ty) => {
#[allow(clippy::missing_errors_doc)]
pub fn $name(number: $numeric, w: &mut dyn Write) -> Result<()> { pub fn $name(number: $numeric, w: &mut dyn Write) -> Result<()> {
match (number.classify(), number.is_sign_negative()) { match (number.classify(), number.is_sign_negative()) {
(FpCategory::Nan, true) => write!(w, "-LUA_NAN_DEFAULT "), (FpCategory::Nan, true) => write!(w, "-LUA_NAN_DEFAULT "),
@ -23,6 +24,7 @@ macro_rules! impl_write_number_nan {
} }
} }
#[allow(clippy::missing_errors_doc)]
pub fn $name_nan(data: &wast::core::NanPattern<$pattern>, w: &mut dyn Write) -> Result<()> { pub fn $name_nan(data: &wast::core::NanPattern<$pattern>, w: &mut dyn Write) -> Result<()> {
use wast::core::NanPattern; use wast::core::NanPattern;
@ -42,6 +44,7 @@ macro_rules! impl_write_number_nan {
impl_write_number_nan!(write_f32, write_f32_nan, f32, wast::token::Float32); impl_write_number_nan!(write_f32, write_f32_nan, f32, wast::token::Float32);
impl_write_number_nan!(write_f64, write_f64_nan, f64, wast::token::Float64); impl_write_number_nan!(write_f64, write_f64_nan, f64, wast::token::Float64);
#[allow(clippy::missing_const_for_fn)]
fn try_into_ast_module(data: QuoteWat) -> Option<WaModule> { fn try_into_ast_module(data: QuoteWat) -> Option<WaModule> {
if let QuoteWat::Wat(Wat::Module(data)) = data { if let QuoteWat::Wat(Wat::Module(data)) = data {
Some(data) Some(data)
@ -54,6 +57,7 @@ pub fn get_name_from_id(id: Option<Id>) -> &str {
id.as_ref().map_or("temp", Id::name) id.as_ref().map_or("temp", Id::name)
} }
#[allow(clippy::missing_errors_doc)]
pub trait Target: Sized { pub trait Target: Sized {
fn executable() -> String; fn executable() -> String;
@ -144,7 +148,7 @@ pub trait Target: Sized {
.join(name) .join(name)
.with_extension("wast.lua"); .with_extension("wast.lua");
std::fs::write(&temp, &data)?; std::fs::write(&temp, data)?;
Self::run_command(&temp) Self::run_command(&temp)
} }
} }

View File

@ -293,10 +293,7 @@ impl<'a> Factory<'a> {
} }
fn start_else(&mut self) { fn start_else(&mut self) {
let ty = match self.target.block_data { let BlockData::If { ty, .. } = self.target.block_data else { unreachable!() };
BlockData::If { ty, .. } => ty,
_ => unreachable!(),
};
self.target.leak_all(); self.target.leak_all();
self.end_block(); self.end_block();
@ -626,7 +623,7 @@ impl<'a> Factory<'a> {
let n = self.target.stack.pop().into(); let n = self.target.stack.pop().into();
let value = self.target.stack.pop().into(); let value = self.target.stack.pop().into();
let data = Statement::MemoryFill(MemoryFill { mem, n, value }); let data = Statement::MemoryFill(MemoryFill { mem, value, n });
self.target.code.push(data); self.target.code.push(data);
} }
@ -634,7 +631,7 @@ impl<'a> Factory<'a> {
Operator::I64Const { value } => self.target.push_constant(value), Operator::I64Const { value } => self.target.push_constant(value),
Operator::F32Const { value } => self.target.push_constant(value.bits()), Operator::F32Const { value } => self.target.push_constant(value.bits()),
Operator::F64Const { value } => self.target.push_constant(value.bits()), Operator::F64Const { value } => self.target.push_constant(value.bits()),
_ => panic!("Unsupported instruction: {:?}", op), _ => panic!("Unsupported instruction: {op:?}"),
} }
} }

View File

@ -17,11 +17,11 @@ pub enum External {
impl From<TypeRef> for External { impl From<TypeRef> for External {
fn from(value: TypeRef) -> Self { fn from(value: TypeRef) -> Self {
match value { match value {
TypeRef::Func(_) => External::Func, TypeRef::Func(_) => Self::Func,
TypeRef::Table(_) => External::Table, TypeRef::Table(_) => Self::Table,
TypeRef::Memory(_) => External::Memory, TypeRef::Memory(_) => Self::Memory,
TypeRef::Global(_) => External::Global, TypeRef::Global(_) => Self::Global,
TypeRef::Tag(_) => External::Tag, TypeRef::Tag(_) => Self::Tag,
} }
} }
} }
@ -29,11 +29,11 @@ impl From<TypeRef> for External {
impl From<ExternalKind> for External { impl From<ExternalKind> for External {
fn from(value: ExternalKind) -> Self { fn from(value: ExternalKind) -> Self {
match value { match value {
ExternalKind::Func => External::Func, ExternalKind::Func => Self::Func,
ExternalKind::Table => External::Table, ExternalKind::Table => Self::Table,
ExternalKind::Memory => External::Memory, ExternalKind::Memory => Self::Memory,
ExternalKind::Global => External::Global, ExternalKind::Global => Self::Global,
ExternalKind::Tag => External::Tag, ExternalKind::Tag => Self::Tag,
} }
} }
} }
@ -199,12 +199,12 @@ impl<'a> Module<'a> {
} }
#[must_use] #[must_use]
pub fn name_section(&self) -> &HashMap<u32, &'a str> { pub const fn name_section(&self) -> &HashMap<u32, &'a str> {
&self.name_section &self.name_section
} }
#[must_use] #[must_use]
pub fn start_section(&self) -> Option<u32> { pub const fn start_section(&self) -> Option<u32> {
self.start_section self.start_section
} }
} }

View File

@ -23,7 +23,7 @@ pub enum LoadType {
impl LoadType { impl LoadType {
#[must_use] #[must_use]
pub fn as_name(self) -> &'static str { pub const fn as_name(self) -> &'static str {
match self { match self {
Self::I32 => "i32", Self::I32 => "i32",
Self::I64 => "i64", Self::I64 => "i64",
@ -85,7 +85,7 @@ pub enum StoreType {
impl StoreType { impl StoreType {
#[must_use] #[must_use]
pub fn as_name(self) -> &'static str { pub const fn as_name(self) -> &'static str {
match self { match self {
Self::I32 => "i32", Self::I32 => "i32",
Self::I64 => "i64", Self::I64 => "i64",
@ -188,7 +188,7 @@ pub enum UnOpType {
impl UnOpType { impl UnOpType {
#[must_use] #[must_use]
pub fn as_name(self) -> (&'static str, &'static str) { pub const fn as_name(self) -> (&'static str, &'static str) {
match self { match self {
Self::Clz_I32 => ("clz", "i32"), Self::Clz_I32 => ("clz", "i32"),
Self::Ctz_I32 => ("ctz", "i32"), Self::Ctz_I32 => ("ctz", "i32"),
@ -373,7 +373,7 @@ pub enum BinOpType {
impl BinOpType { impl BinOpType {
#[must_use] #[must_use]
pub fn as_name(self) -> (&'static str, &'static str) { pub const fn as_name(self) -> (&'static str, &'static str) {
match self { match self {
Self::Add_I32 => ("add", "i32"), Self::Add_I32 => ("add", "i32"),
Self::Sub_I32 => ("sub", "i32"), Self::Sub_I32 => ("sub", "i32"),
@ -520,7 +520,7 @@ pub enum CmpOpType {
impl CmpOpType { impl CmpOpType {
#[must_use] #[must_use]
pub fn as_name(self) -> (&'static str, &'static str) { pub const fn as_name(self) -> (&'static str, &'static str) {
match self { match self {
Self::Eq_I32 => ("eq", "i32"), Self::Eq_I32 => ("eq", "i32"),
Self::Ne_I32 => ("ne", "i32"), Self::Ne_I32 => ("ne", "i32"),
@ -633,7 +633,7 @@ pub struct GetTemporary {
impl GetTemporary { impl GetTemporary {
#[must_use] #[must_use]
pub fn var(&self) -> usize { pub const fn var(&self) -> usize {
self.var self.var
} }
} }
@ -644,7 +644,7 @@ pub struct GetLocal {
impl GetLocal { impl GetLocal {
#[must_use] #[must_use]
pub fn var(&self) -> usize { pub const fn var(&self) -> usize {
self.var self.var
} }
} }
@ -655,7 +655,7 @@ pub struct GetGlobal {
impl GetGlobal { impl GetGlobal {
#[must_use] #[must_use]
pub fn var(&self) -> usize { pub const fn var(&self) -> usize {
self.var self.var
} }
} }
@ -669,22 +669,22 @@ pub struct LoadAt {
impl LoadAt { impl LoadAt {
#[must_use] #[must_use]
pub fn load_type(&self) -> LoadType { pub const fn load_type(&self) -> LoadType {
self.load_type self.load_type
} }
#[must_use] #[must_use]
pub fn memory(&self) -> usize { pub const fn memory(&self) -> usize {
self.memory self.memory
} }
#[must_use] #[must_use]
pub fn offset(&self) -> u32 { pub const fn offset(&self) -> u32 {
self.offset self.offset
} }
#[must_use] #[must_use]
pub fn pointer(&self) -> &Expression { pub const fn pointer(&self) -> &Expression {
&self.pointer &self.pointer
} }
} }
@ -695,7 +695,7 @@ pub struct MemorySize {
impl MemorySize { impl MemorySize {
#[must_use] #[must_use]
pub fn memory(&self) -> usize { pub const fn memory(&self) -> usize {
self.memory self.memory
} }
} }
@ -739,7 +739,7 @@ pub struct UnOp {
impl UnOp { impl UnOp {
#[must_use] #[must_use]
pub fn op_type(&self) -> UnOpType { pub const fn op_type(&self) -> UnOpType {
self.op_type self.op_type
} }
@ -757,7 +757,7 @@ pub struct BinOp {
impl BinOp { impl BinOp {
#[must_use] #[must_use]
pub fn op_type(&self) -> BinOpType { pub const fn op_type(&self) -> BinOpType {
self.op_type self.op_type
} }
@ -780,7 +780,7 @@ pub struct CmpOp {
impl CmpOp { impl CmpOp {
#[must_use] #[must_use]
pub fn op_type(&self) -> CmpOpType { pub const fn op_type(&self) -> CmpOpType {
self.op_type self.op_type
} }
@ -816,17 +816,17 @@ pub struct Align {
impl Align { impl Align {
#[must_use] #[must_use]
pub fn is_aligned(&self) -> bool { pub const fn is_aligned(&self) -> bool {
self.length == 0 || self.new == self.old self.length == 0 || self.new == self.old
} }
#[must_use] #[must_use]
pub fn new_range(&self) -> Range<usize> { pub const fn new_range(&self) -> Range<usize> {
self.new..self.new + self.length self.new..self.new + self.length
} }
#[must_use] #[must_use]
pub fn old_range(&self) -> Range<usize> { pub const fn old_range(&self) -> Range<usize> {
self.old..self.old + self.length self.old..self.old + self.length
} }
} }
@ -838,12 +838,12 @@ pub struct Br {
impl Br { impl Br {
#[must_use] #[must_use]
pub fn target(&self) -> usize { pub const fn target(&self) -> usize {
self.target self.target
} }
#[must_use] #[must_use]
pub fn align(&self) -> &Align { pub const fn align(&self) -> &Align {
&self.align &self.align
} }
} }
@ -866,7 +866,7 @@ impl BrTable {
} }
#[must_use] #[must_use]
pub fn default(&self) -> &Br { pub const fn default(&self) -> &Br {
&self.default &self.default
} }
} }
@ -892,7 +892,7 @@ pub struct Block {
impl Block { impl Block {
#[must_use] #[must_use]
pub fn label_type(&self) -> Option<LabelType> { pub const fn label_type(&self) -> Option<LabelType> {
self.label_type self.label_type
} }
@ -902,7 +902,7 @@ impl Block {
} }
#[must_use] #[must_use]
pub fn last(&self) -> Option<&Terminator> { pub const fn last(&self) -> Option<&Terminator> {
self.last.as_ref() self.last.as_ref()
} }
} }
@ -919,7 +919,7 @@ impl BrIf {
} }
#[must_use] #[must_use]
pub fn target(&self) -> &Br { pub const fn target(&self) -> &Br {
&self.target &self.target
} }
} }
@ -937,12 +937,12 @@ impl If {
} }
#[must_use] #[must_use]
pub fn on_true(&self) -> &Block { pub const fn on_true(&self) -> &Block {
&self.on_true &self.on_true
} }
#[must_use] #[must_use]
pub fn on_false(&self) -> Option<&Block> { pub const fn on_false(&self) -> Option<&Block> {
self.on_false.as_ref() self.on_false.as_ref()
} }
} }
@ -955,7 +955,7 @@ pub struct Call {
impl Call { impl Call {
#[must_use] #[must_use]
pub fn function(&self) -> usize { pub const fn function(&self) -> usize {
self.function self.function
} }
@ -979,7 +979,7 @@ pub struct CallIndirect {
impl CallIndirect { impl CallIndirect {
#[must_use] #[must_use]
pub fn table(&self) -> usize { pub const fn table(&self) -> usize {
self.table self.table
} }
@ -1006,7 +1006,7 @@ pub struct SetTemporary {
impl SetTemporary { impl SetTemporary {
#[must_use] #[must_use]
pub fn var(&self) -> usize { pub const fn var(&self) -> usize {
self.var self.var
} }
@ -1023,7 +1023,7 @@ pub struct SetLocal {
impl SetLocal { impl SetLocal {
#[must_use] #[must_use]
pub fn var(&self) -> usize { pub const fn var(&self) -> usize {
self.var self.var
} }
@ -1040,7 +1040,7 @@ pub struct SetGlobal {
impl SetGlobal { impl SetGlobal {
#[must_use] #[must_use]
pub fn var(&self) -> usize { pub const fn var(&self) -> usize {
self.var self.var
} }
@ -1060,17 +1060,17 @@ pub struct StoreAt {
impl StoreAt { impl StoreAt {
#[must_use] #[must_use]
pub fn store_type(&self) -> StoreType { pub const fn store_type(&self) -> StoreType {
self.store_type self.store_type
} }
#[must_use] #[must_use]
pub fn memory(&self) -> usize { pub const fn memory(&self) -> usize {
self.memory self.memory
} }
#[must_use] #[must_use]
pub fn offset(&self) -> u32 { pub const fn offset(&self) -> u32 {
self.offset self.offset
} }
@ -1093,12 +1093,12 @@ pub struct MemoryGrow {
impl MemoryGrow { impl MemoryGrow {
#[must_use] #[must_use]
pub fn memory(&self) -> usize { pub const fn memory(&self) -> usize {
self.memory self.memory
} }
#[must_use] #[must_use]
pub fn result(&self) -> usize { pub const fn result(&self) -> usize {
self.result self.result
} }
@ -1116,11 +1116,11 @@ pub struct MemoryCopy {
impl MemoryCopy { impl MemoryCopy {
#[must_use] #[must_use]
pub fn dst(&self) -> u32 { pub const fn dst(&self) -> u32 {
self.dst self.dst
} }
#[must_use] #[must_use]
pub fn src(&self) -> u32 { pub const fn src(&self) -> u32 {
self.src self.src
} }
#[must_use] #[must_use]
@ -1137,7 +1137,7 @@ pub struct MemoryFill {
impl MemoryFill { impl MemoryFill {
#[must_use] #[must_use]
pub fn mem(&self) -> u32 { pub const fn mem(&self) -> u32 {
self.mem self.mem
} }
#[must_use] #[must_use]
@ -1180,22 +1180,22 @@ impl FuncData {
} }
#[must_use] #[must_use]
pub fn num_result(&self) -> usize { pub const fn num_result(&self) -> usize {
self.num_result self.num_result
} }
#[must_use] #[must_use]
pub fn num_param(&self) -> usize { pub const fn num_param(&self) -> usize {
self.num_param self.num_param
} }
#[must_use] #[must_use]
pub fn num_stack(&self) -> usize { pub const fn num_stack(&self) -> usize {
self.num_stack self.num_stack
} }
#[must_use] #[must_use]
pub fn code(&self) -> &Block { pub const fn code(&self) -> &Block {
&self.code &self.code
} }
} }

View File

@ -17,7 +17,7 @@ pub struct Slot {
} }
impl Slot { impl Slot {
fn is_temporary(&self, id: usize) -> bool { const fn is_temporary(&self, id: usize) -> bool {
matches!(self.data, Expression::GetTemporary(ref v) if v.var() == id) matches!(self.data, Expression::GetTemporary(ref v) if v.var() == id)
} }