From c1c350f81c3e7bda00dcf95d2ebd8fb89d7eff71 Mon Sep 17 00:00:00 2001 From: Aleksey Yakovlev Date: Thu, 11 Jul 2024 11:31:28 +0700 Subject: [PATCH] clippy run --- src/cli/mod.rs | 4 ++-- src/compiler/rst/compiler.rs | 8 ++------ src/compiler/rst/node.rs | 19 ++----------------- src/compiler/rst/scope.rs | 9 ++++----- src/main.rs | 4 +++- src/util/byte_buffer.rs | 2 +- 6 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index e30320b..3d2ceeb 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,7 +1,7 @@ use std::fs::File; use std::io::Write; use std::panic::catch_unwind; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::thread::sleep; use std::time::{Duration, Instant}; @@ -175,7 +175,7 @@ impl Cli { let compiler = HexoCompiler::new(context); let source_path = Path::new(&source); - let compiler_source = FileCompilerSource::new(&source_path); + let compiler_source = FileCompilerSource::new(source_path); let compilation_result = compiler .compile(&compiler_source) diff --git a/src/compiler/rst/compiler.rs b/src/compiler/rst/compiler.rs index 3feb976..b61f08f 100644 --- a/src/compiler/rst/compiler.rs +++ b/src/compiler/rst/compiler.rs @@ -28,11 +28,7 @@ impl RstCompiler<'_> { let bb = self.build_bytes(scope_id, &mut scope, cst.main().emits())?; - Ok(HexoFile::new( - cst.path(), - scope, - bb, - )) + Ok(HexoFile::new(bb)) } fn build_bytes( @@ -89,7 +85,7 @@ impl RstCompiler<'_> { Error::NativeFunctionIsUnsafe { name: native_function.signature().name().to_string() } - ) + ); } let executor = native_function.executor(); diff --git a/src/compiler/rst/node.rs b/src/compiler/rst/node.rs index f65e320..c1828d0 100644 --- a/src/compiler/rst/node.rs +++ b/src/compiler/rst/node.rs @@ -1,32 +1,17 @@ -use crate::compiler::rst::scope::CompilationScope; use crate::util::byte_buffer::ByteBuffer; -use std::path::{Path, PathBuf}; #[derive(Debug)] pub(crate) struct HexoFile { - path: PathBuf, - context: CompilationScope, emits: ByteBuffer, } impl HexoFile { - - pub(crate) fn new(path: &Path, context: CompilationScope, emits: ByteBuffer) -> HexoFile { + pub(crate) fn new(emits: ByteBuffer) -> HexoFile { HexoFile { - path: path.to_path_buf(), - context, - emits, + emits: emits, } } - pub(crate) fn path(&self) -> &Path { - &self.path - } - - pub(crate) fn context(&self) -> &CompilationScope { - &self.context - } - pub(crate) fn emits(&self) -> &ByteBuffer { &self.emits } diff --git a/src/compiler/rst/scope.rs b/src/compiler/rst/scope.rs index 839c0fb..86703f7 100644 --- a/src/compiler/rst/scope.rs +++ b/src/compiler/rst/scope.rs @@ -1,9 +1,10 @@ +use std::collections::HashMap; +use std::path::Path; + use crate::compiler::cst::CstEmitStatement; use crate::compiler::native_fn::{NativeFunction, NativeFunctionIndex}; -use crate::util::id::HexoId; use crate::util::byte_buffer::ByteBuffer; -use std::collections::HashMap; -use std::path::{Path, PathBuf}; +use crate::util::id::HexoId; #[derive(Clone, Debug)] pub(crate) struct ConstantBinding { @@ -27,7 +28,6 @@ pub(crate) struct LocalCompilationScope { #[derive(Clone, Debug)] pub(crate) struct CompilationScope { - self_path: PathBuf, local_scopes: HashMap, native_function_index: NativeFunctionIndex, } @@ -35,7 +35,6 @@ pub(crate) struct CompilationScope { impl CompilationScope { pub(crate) fn new(path: &Path) -> CompilationScope { CompilationScope { - self_path: path.to_path_buf(), local_scopes: HashMap::new(), native_function_index: NativeFunctionIndex::new(), } diff --git a/src/main.rs b/src/main.rs index 7931aee..181b7c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ #![feature(test)] - +#![allow( + redundant_field_names +)] use crate::cli::Cli; diff --git a/src/util/byte_buffer.rs b/src/util/byte_buffer.rs index d1ca241..5c67c55 100644 --- a/src/util/byte_buffer.rs +++ b/src/util/byte_buffer.rs @@ -95,7 +95,7 @@ impl From> for ByteBuffer { } mod test { - use crate::util::byte_buffer::ByteBuffer; + use super::ByteBuffer; #[test] fn byte_push() {