From 8223dccc245d84936231216ddd4590590746119e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20H=C3=B6lting?= <87192362+moritz-hoelting@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:27:25 +0100 Subject: [PATCH] fix compilation errors depending on feature selection and update dependency version --- Cargo.toml | 18 +++++++++--------- src/lib.rs | 1 + src/transpile/error.rs | 3 ++- src/transpile/mod.rs | 18 +++++++++++++++++- src/transpile/transpiler.rs | 14 ++++---------- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 541c098..8e17f4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,26 +19,26 @@ default = ["fs_access", "lua", "shulkerbox", "zip"] fs_access = ["shulkerbox?/fs_access"] lua = ["dep:mlua"] serde = ["dep:serde", "shulkerbox?/serde"] -shulkerbox = ["dep:shulkerbox"] +shulkerbox = ["dep:shulkerbox", "dep:chksum-md5"] zip = ["shulkerbox?/zip"] [target.'cfg(target_arch = "wasm32")'.dependencies] path-absolutize = { version = "3.1.1", features = ["use_unix_paths_on_wasm"] } [dependencies] -chksum-md5 = "0.0.0" -colored = "2.1.0" +chksum-md5 = { version = "0.1.0", optional = true } +colored = "3.0.0" derive_more = { version = "1.0.0", default-features = false, features = ["deref", "deref_mut", "from"] } enum-as-inner = "0.6.0" getset = "0.1.2" -itertools = "0.13.0" -mlua = { version = "0.10.0", features = ["lua54", "vendored"], optional = true } +itertools = "0.14.0" +mlua = { version = "0.10.2", features = ["lua54", "vendored"], optional = true } path-absolutize = "3.1.1" -pathdiff = "0.2.2" -serde = { version = "1.0.214", features = ["derive", "rc"], optional = true } +pathdiff = "0.2.3" +serde = { version = "1.0.217", features = ["derive", "rc"], optional = true } shulkerbox = { version = "0.1.0", default-features = false, optional = true } strsim = "0.11.1" strum = { version = "0.26.2", features = ["derive"] } strum_macros = "0.26.4" -thiserror = "1.0.65" -tracing = "0.1.40" +thiserror = "2.0.11" +tracing = "0.1.41" diff --git a/src/lib.rs b/src/lib.rs index ec35d2d..9e530a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ #![warn(missing_docs, clippy::all, clippy::pedantic)] #![allow(clippy::missing_panics_doc, clippy::missing_const_for_fn)] +#[cfg(feature = "shulkerbox")] pub use shulkerbox; pub mod base; diff --git a/src/transpile/error.rs b/src/transpile/error.rs index 24a50a8..abdf88d 100644 --- a/src/transpile/error.rs +++ b/src/transpile/error.rs @@ -13,7 +13,7 @@ use crate::{ syntax::syntax_tree::expression::Expression, }; -use super::transpiler::FunctionData; +use super::FunctionData; /// Errors that can occur during transpilation. #[allow(clippy::module_name_repetitions, missing_docs)] @@ -44,6 +44,7 @@ pub struct MissingFunctionDeclaration { } impl MissingFunctionDeclaration { + #[cfg_attr(not(feature = "shulkerbox"), expect(unused))] pub(super) fn from_context( identifier_span: Span, functions: &BTreeMap<(String, String), FunctionData>, diff --git a/src/transpile/mod.rs b/src/transpile/mod.rs index 0ef8314..6ca242f 100644 --- a/src/transpile/mod.rs +++ b/src/transpile/mod.rs @@ -1,9 +1,14 @@ //! The transpile module is responsible for transpiling the abstract syntax tree into a data pack. +use std::collections::HashMap; + +use crate::{base::source_file::Span, syntax::syntax_tree::statement::Statement}; + #[doc(hidden)] #[cfg(feature = "shulkerbox")] pub mod conversions; mod error; + #[doc(inline)] #[allow(clippy::module_name_repetitions)] pub use error::{TranspileError, TranspileResult}; @@ -11,7 +16,18 @@ pub use error::{TranspileError, TranspileResult}; pub mod lua; #[cfg(feature = "shulkerbox")] mod transpiler; -#[doc(inline)] +#[cfg(feature = "shulkerbox")] +#[cfg_attr(feature = "shulkerbox", doc(inline))] pub use transpiler::Transpiler; +#[cfg(feature = "shulkerbox")] mod util; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(super) struct FunctionData { + pub(super) namespace: String, + pub(super) identifier_span: Span, + pub(super) statements: Vec, + pub(super) public: bool, + pub(super) annotations: HashMap>, +} diff --git a/src/transpile/transpiler.rs b/src/transpile/transpiler.rs index 19462ff..beb5453 100644 --- a/src/transpile/transpiler.rs +++ b/src/transpile/transpiler.rs @@ -26,7 +26,10 @@ use crate::{ transpile::error::{ConflictingFunctionNames, MissingFunctionDeclaration}, }; -use super::error::{TranspileError, TranspileResult, UnexpectedExpression}; +use super::{ + error::{TranspileError, TranspileResult, UnexpectedExpression}, + FunctionData, +}; /// A transpiler for `Shulkerscript`. #[derive(Debug)] @@ -40,15 +43,6 @@ pub struct Transpiler { aliases: HashMap<(String, String), (String, String)>, } -#[derive(Debug, Clone, PartialEq, Eq)] -pub(super) struct FunctionData { - pub(super) namespace: String, - pub(super) identifier_span: Span, - pub(super) statements: Vec, - pub(super) public: bool, - pub(super) annotations: HashMap>, -} - impl Transpiler { /// Creates a new transpiler. #[must_use]