diff --git a/fastn-core/src/commands/fmt.rs b/fastn-core/src/commands/fmt.rs index 9fbd2c86d..f53a136c7 100644 --- a/fastn-core/src/commands/fmt.rs +++ b/fastn-core/src/commands/fmt.rs @@ -252,11 +252,7 @@ fn section(input: &mut String) -> Option
{ if !trimmed_line.is_empty() { trimmed_line = format!( "{}{}", - " ".repeat(if current_leading_spaces_count > leading_spaces_count { - current_leading_spaces_count - leading_spaces_count - } else { - 0 - }), + " ".repeat(current_leading_spaces_count.saturating_sub(leading_spaces_count)), trimmed_line.trim() ); } diff --git a/fastn-core/src/config/mod.rs b/fastn-core/src/config/mod.rs index 6162f9ada..a8b5f3a27 100644 --- a/fastn-core/src/config/mod.rs +++ b/fastn-core/src/config/mod.rs @@ -410,10 +410,10 @@ impl Config { generated_style.push('\n'); entry = package.next(); } - return match generated_style.trim().is_empty() { + match generated_style.trim().is_empty() { false => format!("", generated_style), _ => "".to_string(), - }; + } } pub(crate) async fn download_fonts( diff --git a/fastn-core/src/library2022/processor/figma_typography_tokens.rs b/fastn-core/src/library2022/processor/figma_typography_tokens.rs index ca8ab2685..b115c72ef 100644 --- a/fastn-core/src/library2022/processor/figma_typography_tokens.rs +++ b/fastn-core/src/library2022/processor/figma_typography_tokens.rs @@ -251,7 +251,7 @@ fn extract_type_data( } fn extract_raw_data(property_value: Option) -> Option { - return match property_value.as_ref() { + match property_value.as_ref() { Some(fastn_resolved::PropertyValue::Value { value, .. }) => match value { fastn_resolved::Value::String { text } => Some(ValueType { value: text.to_string(), @@ -295,7 +295,7 @@ fn extract_raw_data(property_value: Option) -> Op Some(fastn_resolved::PropertyValue::Clone { .. }) => None, Some(fastn_resolved::PropertyValue::FunctionCall { .. }) => None, None => None, - }; + } } #[derive(Debug, Default, Serialize, Deserialize)] diff --git a/fastn-core/src/package/redirects.rs b/fastn-core/src/package/redirects.rs index 13da26c51..8ac44e2be 100644 --- a/fastn-core/src/package/redirects.rs +++ b/fastn-core/src/package/redirects.rs @@ -142,13 +142,13 @@ pub fn find_redirect<'a>(redirects: &'a ftd::Map, path: &str) -> Option< .trim_end_matches(".ftd") ); - return if redirects.contains_key(original) { + if redirects.contains_key(original) { redirects.get(original) } else if redirects.contains_key(fixed.as_str()) { redirects.get(fixed.as_str()) } else { None - }; + } } #[cfg(test)] diff --git a/fastn-core/src/utils.rs b/fastn-core/src/utils.rs index 8378a7a69..141c94c3d 100644 --- a/fastn-core/src/utils.rs +++ b/fastn-core/src/utils.rs @@ -292,7 +292,7 @@ pub struct Timer<'a> { msg: &'a str, } -impl<'a> Timer<'a> { +impl Timer<'_> { pub fn it(&self, a: T) -> T { use colored::Colorize; @@ -607,6 +607,7 @@ async fn get_extra_js( ) } +#[expect(unused)] async fn get_extra_css( config: &fastn_core::Config, external_css: &[String], diff --git a/fastn-resolved/src/lib.rs b/fastn-resolved/src/lib.rs index cbb3b4205..2abb62dee 100644 --- a/fastn-resolved/src/lib.rs +++ b/fastn-resolved/src/lib.rs @@ -34,16 +34,16 @@ pub type Map = std::collections::BTreeMap; #[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] pub enum Definition { - SymbolAlias { - symbol: String, - alias: String, - line_number: usize, - }, - ModuleAlias { - module: String, - alias: String, - line_number: usize, - }, + // SymbolAlias { + // symbol: String, + // alias: String, + // line_number: usize, + // }, + // ModuleAlias { + // module: String, + // alias: String, + // line_number: usize, + // }, Record(fastn_resolved::Record), OrType(fastn_resolved::OrType), OrTypeWithVariant { @@ -74,8 +74,8 @@ impl Definition { fastn_resolved::Definition::WebComponent(w) => w.name.to_string(), fastn_resolved::Definition::Export { to, .. } => to.to_string(), // TODO: check if the following two are valid - Definition::SymbolAlias { alias, .. } => alias.to_string(), - Definition::ModuleAlias { alias, .. } => alias.to_string(), + // Definition::SymbolAlias { alias, .. } => alias.to_string(), + // Definition::ModuleAlias { alias, .. } => alias.to_string(), } } @@ -89,8 +89,8 @@ impl Definition { Definition::OrTypeWithVariant { variant, .. } => variant.line_number(), Definition::WebComponent(w) => w.line_number, Definition::Export { line_number, .. } => *line_number, - Definition::SymbolAlias { line_number, .. } => *line_number, - Definition::ModuleAlias { line_number, .. } => *line_number, + // Definition::SymbolAlias { line_number, .. } => *line_number, + // Definition::ModuleAlias { line_number, .. } => *line_number, } } diff --git a/fastn-runtime/Cargo.toml b/fastn-runtime/Cargo.toml index d67c069ed..4528fcb41 100644 --- a/fastn-runtime/Cargo.toml +++ b/fastn-runtime/Cargo.toml @@ -10,6 +10,7 @@ homepage.workspace = true [features] owned-tdoc = ["fastn-resolved/owned-tdoc"] +default = ["owned-tdoc"] [dependencies] fastn-js.workspace = true diff --git a/v0.5/Cargo.lock b/v0.5/Cargo.lock index b3cc58566..8da54919d 100644 --- a/v0.5/Cargo.lock +++ b/v0.5/Cargo.lock @@ -87,9 +87,9 @@ dependencies = [ [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" @@ -172,13 +172,9 @@ dependencies = [ "async-trait", "fastn-compiler", "fastn-core", - "fastn-resolved", "fastn-runtime", - "fastn-section", "fastn-unresolved", - "id-arena", "serde_json", - "string-interner", "tokio", ] @@ -271,7 +267,6 @@ dependencies = [ "fastn-builtins", "fastn-resolved", "fastn-section", - "id-arena", "serde_json", "string-interner", ] @@ -317,18 +312,6 @@ dependencies = [ "foldhash", ] -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - -[[package]] -name = "id-arena" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" - [[package]] name = "ident_case" version = "1.0.1" @@ -416,11 +399,10 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi", "libc", "wasi", "windows-sys", @@ -749,9 +731,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys", diff --git a/v0.5/Cargo.toml b/v0.5/Cargo.toml index b02c23b40..651f2cf65 100644 --- a/v0.5/Cargo.toml +++ b/v0.5/Cargo.toml @@ -44,13 +44,12 @@ fastn-core = { path = "fastn-core" } fastn-jdebug = { version = "0.1.0", path = "fastn-jdebug" } fastn-section = { path = "fastn-section" } fastn-static = { path = "fastn-static" } -fastn-resolved = { path = "../fastn-resolved" } -fastn-runtime = { path = "../fastn-runtime" } +fastn-resolved = { path = "../fastn-resolved", default-features = false } +fastn-runtime = { path = "../fastn-runtime", default-features = false } fastn-builtins = { path = "../fastn-builtins" } fastn-js = { path = "../fastn-js" } fastn-unresolved = { path = "fastn-unresolved" } fastn-update = { path = "fastn-update" } -id-arena = "2" indexmap = "2" insta = { version = "1", features = ["yaml", "glob"] } itertools = "0.13" diff --git a/v0.5/fastn-compiler/src/compiler.rs b/v0.5/fastn-compiler/src/compiler.rs index 50baa5140..dbee11181 100644 --- a/v0.5/fastn-compiler/src/compiler.rs +++ b/v0.5/fastn-compiler/src/compiler.rs @@ -9,7 +9,7 @@ pub(crate) struct Compiler { /// checkout resolve_document for why this is an Option content: Option>, pub(crate) document: fastn_unresolved::Document, - auto_import_scope: fastn_unresolved::SFId, + // auto_import_scope: fastn_unresolved::SFId, } impl Compiler { @@ -18,14 +18,13 @@ impl Compiler { source: &str, package: &str, module: &str, - auto_import_scope: fastn_unresolved::SFId, + // auto_import_scope: fastn_unresolved::SFId, mut arena: fastn_unresolved::Arena, ) -> Self { let mut document = fastn_unresolved::parse( fastn_unresolved::Module::new(package, module, &mut arena), source, &mut arena, - auto_import_scope, ); let content = Some(document.content); document.content = vec![]; @@ -37,7 +36,6 @@ impl Compiler { content, document, definitions_used: Default::default(), - auto_import_scope, } } @@ -47,10 +45,7 @@ impl Compiler { ) { self.definitions_used .extend(symbols_to_fetch.iter().cloned()); - let definitions = self - .symbols - .lookup(&mut self.arena, symbols_to_fetch, self.auto_import_scope) - .await; + let definitions = self.symbols.lookup(&mut self.arena, symbols_to_fetch).await; for definition in definitions { // the following is only okay if our symbol store only returns unresolved definitions, // some other store might return resolved definitions, and we need to handle that. @@ -221,10 +216,10 @@ pub async fn compile( source: &str, package: &str, module: &str, - auto_import_scope: fastn_unresolved::SFId, + // auto_import_scope: fastn_unresolved::SFId, arena: fastn_unresolved::Arena, ) -> Result { - Compiler::new(symbols, source, package, module, auto_import_scope, arena) + Compiler::new(symbols, source, package, module, arena) .compile() .await } diff --git a/v0.5/fastn-compiler/src/symbols.rs b/v0.5/fastn-compiler/src/symbols.rs index b53f886e4..1fa77a7d8 100644 --- a/v0.5/fastn-compiler/src/symbols.rs +++ b/v0.5/fastn-compiler/src/symbols.rs @@ -14,6 +14,6 @@ pub trait SymbolStore { &mut self, arena: &mut fastn_unresolved::Arena, symbols: &std::collections::HashSet, - auto_imports: fastn_unresolved::SFId, - ); + // auto_imports: fastn_unresolved::SFId, + ) -> Vec; } diff --git a/v0.5/fastn-core/src/config/mod.rs b/v0.5/fastn-core/src/config/mod.rs index 8f86db58e..dde26febe 100644 --- a/v0.5/fastn-core/src/config/mod.rs +++ b/v0.5/fastn-core/src/config/mod.rs @@ -3,12 +3,12 @@ mod read; #[allow(dead_code)] pub struct Config { sitemap: Sitemap, - pub auto_import_scope: fastn_unresolved::SFId, + // pub auto_import_scope: fastn_unresolved::SFId, redirects: Vec, dynamic_routes: Vec, } -pub struct AutoImport {} +// pub struct AutoImport {} pub struct DynamicRoute {} pub struct Redirect {} pub struct Sitemap {} diff --git a/v0.5/fastn-core/src/config/read.rs b/v0.5/fastn-core/src/config/read.rs index d259a0050..8fbc4a553 100644 --- a/v0.5/fastn-core/src/config/read.rs +++ b/v0.5/fastn-core/src/config/read.rs @@ -1,11 +1,11 @@ impl fastn_core::Config { pub async fn read( _fastn_ftd: fastn_section::Document, - arena: &mut fastn_unresolved::Arena, + _arena: &mut fastn_unresolved::Arena, ) -> Result { Ok(fastn_core::Config { sitemap: fastn_core::Sitemap {}, - auto_import_scope: desugar_auto_imports(arena, &[]), + // auto_import_scope: desugar_auto_imports(arena, &[]), redirects: vec![], dynamic_routes: vec![], }) @@ -17,9 +17,9 @@ pub enum ReadError { SourceError(fastn_section::Error), } -fn desugar_auto_imports( - arena: &mut fastn_unresolved::Arena, - _auto_imports: &[fastn_core::config::AutoImport], -) -> fastn_unresolved::SFId { - arena.new_scope("auto-imports") -} +// fn desugar_auto_imports( +// arena: &mut fastn_unresolved::Arena, +// _auto_imports: &[fastn_core::config::AutoImport], +// ) -> fastn_unresolved::SFId { +// arena.new_scope("auto-imports") +// } diff --git a/v0.5/fastn-section/src/parser/section.rs b/v0.5/fastn-section/src/parser/section.rs index b358a4821..a2237ba1d 100644 --- a/v0.5/fastn-section/src/parser/section.rs +++ b/v0.5/fastn-section/src/parser/section.rs @@ -11,9 +11,9 @@ pub fn section( caption, headers: fastn_section::parser::headers(scanner), body: fastn_section::parser::body(scanner), - children: vec![], // children is populated by the wiggin::ender. - is_commented: false, // TODO - has_end: false, // has_end is populated by the wiggin::ender. + children: vec![], // children is populated by the wiggin::ender. + is_commented: false, // TODO + has_end: false, // has_end is populated by the wiggin::ender. }) } diff --git a/v0.5/fastn-unresolved/Cargo.toml b/v0.5/fastn-unresolved/Cargo.toml index 34335e05f..977de4cf8 100644 --- a/v0.5/fastn-unresolved/Cargo.toml +++ b/v0.5/fastn-unresolved/Cargo.toml @@ -13,7 +13,6 @@ arcstr.workspace = true fastn-builtins.workspace = true fastn-section.workspace = true fastn-resolved.workspace = true -id-arena.workspace = true string-interner.workspace = true [dev-dependencies] diff --git a/v0.5/fastn-unresolved/src/lib.rs b/v0.5/fastn-unresolved/src/lib.rs index 2489e8bab..1b0ae516e 100644 --- a/v0.5/fastn-unresolved/src/lib.rs +++ b/v0.5/fastn-unresolved/src/lib.rs @@ -26,22 +26,8 @@ pub type Bag = std::collections::HashMap, -} - -pub type SFId = id_arena::Id; -pub type SFArena = id_arena::Arena; -// pub type ScopeStackId = id_arena::Id; - #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Symbol { // 8 bytes @@ -64,7 +50,6 @@ pub struct Module { #[derive(Debug, Clone)] pub struct Document { - pub scope: [SFId; 2], pub module: fastn_unresolved::Module, pub module_doc: Option, pub definitions: Vec, @@ -81,7 +66,6 @@ pub struct Definition { /// we will keep the builtins not as ScopeFrame, but as plain hashmap. /// we have two scopes at this level, the auto-imports, and scope of all symbols explicitly /// imported/defined in the document this definition exists in. - pub scope: [SFId; 2], pub doc: Option, /// resolving an identifier means making sure it is unique in the document, and performing /// other checks. diff --git a/v0.5/fastn-unresolved/src/parser/function_definition.rs b/v0.5/fastn-unresolved/src/parser/function_definition.rs index 28c8d5055..6c099d15f 100644 --- a/v0.5/fastn-unresolved/src/parser/function_definition.rs +++ b/v0.5/fastn-unresolved/src/parser/function_definition.rs @@ -44,7 +44,6 @@ pub(super) fn function_definition( document.definitions.push( fastn_unresolved::Definition { symbol: Default::default(), - scope: document.scope, doc: Default::default(), visibility, name: fastn_section::Identifier { name }.into(), diff --git a/v0.5/fastn-unresolved/src/parser/mod.rs b/v0.5/fastn-unresolved/src/parser/mod.rs index 5c0c38f00..7a72b849b 100644 --- a/v0.5/fastn-unresolved/src/parser/mod.rs +++ b/v0.5/fastn-unresolved/src/parser/mod.rs @@ -6,14 +6,12 @@ pub fn parse( module: fastn_unresolved::Module, source: &str, arena: &mut fastn_unresolved::Arena, - auto_imports: fastn_unresolved::SFId, + // auto_imports: fastn_unresolved::SFId, ) -> fastn_unresolved::Document { - let scope = arena.new_scope("module"); let (mut document, sections) = fastn_unresolved::Document::new( module, fastn_section::Document::parse(&arcstr::ArcStr::from(source)), - auto_imports, - scope, + // auto_imports, ); // todo: first go through just the imports and desugar them @@ -70,14 +68,10 @@ where let mut arena = fastn_unresolved::Arena::default(); let module = fastn_unresolved::Module::new("main", "", &mut arena); - let auto_import_scope = arena.new_scope("auto-import"); - let module_scope = arena.new_scope("module"); let (mut document, sections) = fastn_unresolved::Document::new( module, fastn_section::Document::parse(&arcstr::ArcStr::from(source)), - auto_import_scope, - module_scope, ); let section = { diff --git a/v0.5/fastn-unresolved/src/utils.rs b/v0.5/fastn-unresolved/src/utils.rs index b637ea4e3..a18eedb2b 100644 --- a/v0.5/fastn-unresolved/src/utils.rs +++ b/v0.5/fastn-unresolved/src/utils.rs @@ -2,13 +2,11 @@ impl fastn_unresolved::Document { pub(crate) fn new( module: fastn_unresolved::Module, document: fastn_section::Document, - auto_import_scope: fastn_unresolved::SFId, - module_scope: fastn_unresolved::SFId, + // auto_import_scope: fastn_unresolved::SFId, ) -> (fastn_unresolved::Document, Vec) { ( fastn_unresolved::Document { module, - scope: [auto_import_scope, module_scope], module_doc: document.module_doc, definitions: vec![], content: vec![], @@ -232,12 +230,3 @@ impl fastn_unresolved::Module { } } } - -impl fastn_unresolved::Arena { - pub fn new_scope(&mut self, name: &str) -> fastn_unresolved::SFId { - self.sfa.alloc(fastn_unresolved::ScopeFrame { - name: name.to_string(), - bag: Default::default(), - }) - } -} diff --git a/v0.5/fastn/Cargo.toml b/v0.5/fastn/Cargo.toml index c576ec034..9816dc9c1 100644 --- a/v0.5/fastn/Cargo.toml +++ b/v0.5/fastn/Cargo.toml @@ -12,12 +12,7 @@ homepage.workspace = true async-trait.workspace = true fastn-core.workspace = true fastn-compiler.workspace = true -fastn-section.workspace = true -fastn-resolved.workspace = true fastn-runtime.workspace = true fastn-unresolved.workspace = true -id-arena.workspace = true serde_json.workspace = true -string-interner.workspace = true tokio.workspace = true -# fastn-runtime.workspace = true diff --git a/v0.5/fastn/src/commands/render.rs b/v0.5/fastn/src/commands/render.rs index 56e42709f..3b615c5f1 100644 --- a/v0.5/fastn/src/commands/render.rs +++ b/v0.5/fastn/src/commands/render.rs @@ -11,7 +11,7 @@ impl fastn::commands::Render { } async fn render_document( - config: &fastn_core::Config, + _config: &fastn_core::Config, path: &str, _data: serde_json::Value, _strict: bool, @@ -20,16 +20,9 @@ async fn render_document( let source = std::fs::File::open(path) .and_then(std::io::read_to_string) .unwrap(); - let o = fastn_compiler::compile( - Box::new(fastn::Symbols {}), - &source, - "main", - "", - config.auto_import_scope, - arena, - ) - .await - .unwrap(); + let o = fastn_compiler::compile(Box::new(fastn::Symbols {}), &source, "main", "", arena) + .await + .unwrap(); let h = fastn_runtime::HtmlData::from_cd(o); let html = h.to_test_html(); std::fs::write(path.replace(".ftd", ".html"), html).unwrap(); diff --git a/v0.5/fastn/src/lib.rs b/v0.5/fastn/src/lib.rs index 6de08773f..60c7518d7 100644 --- a/v0.5/fastn/src/lib.rs +++ b/v0.5/fastn/src/lib.rs @@ -1,8 +1,14 @@ +#![deny(unused_crate_dependencies)] #![allow(clippy::derive_partial_eq_without_eq, clippy::get_first)] #![warn(clippy::used_underscore_binding)] extern crate self as fastn; +// we are adding this so we can continue to use unused_crate_dependencies, as only +// main depends on tokio, and if we do not have the following unused_crate_dependencies +// complains +use tokio as _; + pub mod commands; mod symbols; diff --git a/v0.5/fastn/src/symbols.rs b/v0.5/fastn/src/symbols.rs index 4b02b82fc..d0e987510 100644 --- a/v0.5/fastn/src/symbols.rs +++ b/v0.5/fastn/src/symbols.rs @@ -6,7 +6,6 @@ impl Symbols { &mut self, arena: &mut fastn_unresolved::Arena, (file, module): (String, fastn_unresolved::Module), - auto_import_scope: fastn_unresolved::SFId, ) -> Vec { // we need to fetch the symbol from the store let source = match std::fs::File::open(file.as_str()).and_then(std::io::read_to_string) { @@ -17,7 +16,7 @@ impl Symbols { } }; - let d = fastn_unresolved::parse(module.clone(), &source, arena, auto_import_scope); + let d = fastn_unresolved::parse(module.clone(), &source, arena); d.definitions .into_iter() @@ -40,17 +39,17 @@ impl fastn_compiler::SymbolStore for Symbols { &mut self, arena: &mut fastn_unresolved::Arena, symbols: &std::collections::HashSet, - auto_import_scope: fastn_unresolved::SFId, - ) { + // auto_import_scope: fastn_unresolved::SFId, + ) -> Vec { let unique_modules = symbols .iter() .map(|s| file_for_symbol(s, arena)) .collect::>(); - let _: Vec<_> = unique_modules + unique_modules .into_iter() - .map(|m| self.find_all_definitions_in_a_module(arena, m, auto_import_scope)) - .collect(); + .flat_map(|m| self.find_all_definitions_in_a_module(arena, m)) + .collect() } }