From e30ecd865a19be075f1580bda7c6cc449d201514 Mon Sep 17 00:00:00 2001 From: Sofia Date: Tue, 17 Mar 2026 21:56:42 +0200 Subject: [PATCH] Remove a bunch of warnings --- src/ast.rs | 8 ++++---- src/compile.rs | 7 +++---- src/lib.rs | 14 +++++++------- src/vm.rs | 33 +++++++++++++-------------------- 4 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index d0023d0..5a855b8 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -134,7 +134,7 @@ pub struct Function { pub name: Option>, pub params: Vec>, pub block: Block, - pub meta: Metadata, + pub _meta: Metadata, } impl Parse for Function { @@ -165,7 +165,7 @@ impl Parse for Function { name, params, block, - meta: Metadata::produce(&mut stream, pre), + _meta: Metadata::produce(&mut stream, pre), }) } } @@ -183,7 +183,7 @@ impl Parse for String { #[derive(Debug, Clone)] pub struct Block { pub statements: Vec>, - pub meta: Metadata, + pub _meta: Metadata, } impl Parse for Block { @@ -200,7 +200,7 @@ impl Parse for Block { Ok(Block { statements, - meta: Metadata::produce(&mut stream, pre), + _meta: Metadata::produce(&mut stream, pre), }) } } diff --git a/src/compile.rs b/src/compile.rs index d6540d8..a8d5087 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet}; use crate::{ ast::{AccessModifier, BinaryOperator, Block, Expression, Literal, Statement, UnaryOperator}, - vm::{Constant, Instruction, LuaBool, VMFloat}, + vm::{Constant, Instruction, LuaBool}, }; #[derive(Clone, Debug)] @@ -16,7 +16,7 @@ impl State { self.constants .iter() .enumerate() - .find(|(i, c)| *c == value) + .find(|(_, c)| *c == value) .unwrap() .0 as u32 } @@ -218,8 +218,7 @@ impl Statement { None => { for (i, (name, indexes)) in names.iter().enumerate() { if indexes.len() > 0 { - let mut table_reg = if let Some(reg) = scope.locals.get(&name.kind) - { + let table_reg = if let Some(reg) = scope.locals.get(&name.kind) { *reg } else if let Some(upval_reg) = scope.upvalues.get(&name.kind) { let local = scope.register_counter.next(); diff --git a/src/lib.rs b/src/lib.rs index 2519ccb..2f6dc4a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use std::{fmt::Debug, marker::PhantomData, path::PathBuf}; +use std::{fmt::Debug, path::PathBuf}; use thiserror::Error; @@ -11,9 +11,9 @@ use crate::{ vm::{ClosureRunner, VirtualMachine}, }; -pub mod ast; -pub mod compile; -pub mod token_stream; +mod ast; +mod compile; +mod token_stream; pub mod vm; #[derive(Error, Debug)] @@ -26,9 +26,9 @@ pub enum CompilationError { #[derive(Clone)] pub struct CompilationUnit { - instructions: Vec, - state: compile::State, - constants: Vec, + pub instructions: Vec, + pub state: compile::State, + pub constants: Vec, } impl Debug for CompilationUnit { diff --git a/src/vm.rs b/src/vm.rs index c5f284e..b220151 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -1,17 +1,10 @@ use thiserror::Error; -use std::{ - cell::{RefCell, RefMut}, - collections::HashMap, - fmt::Debug, - hash::Hash, - rc::Rc, -}; +use std::{cell::RefCell, collections::HashMap, fmt::Debug, hash::Hash, rc::Rc}; use crate::{ CompilationUnit, ast::{BinaryOperator, UnaryOperator}, - compile, }; #[derive(Clone, Hash, PartialEq, Eq, Copy)] @@ -221,7 +214,7 @@ pub enum RuntimeError { } #[derive(Debug, Clone, Default)] -pub struct Environment { +pub(crate) struct Environment { pub globals: HashMap>>, } @@ -515,10 +508,10 @@ impl VirtualMachine { #[derive(Debug, Clone)] pub struct Closure { - pub vm: VirtualMachine, - pub prototype: u32, - pub environment: Rc>, - pub upvalues: HashMap>>, + vm: VirtualMachine, + prototype: u32, + environment: Rc>, + upvalues: HashMap>>, } impl Closure { @@ -551,13 +544,13 @@ impl Closure { } pub struct ClosureRunner { - pub closure: Closure, - pub program_counter: usize, - pub stack: HashMap>>, - pub inner: Option>, - pub function_register: u16, - pub return_registers: Vec, - pub top: u16, + closure: Closure, + program_counter: usize, + stack: HashMap>>, + inner: Option>, + function_register: u16, + return_registers: Vec, + top: u16, } #[derive(Clone, Debug)]