Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 30, 2024
1 parent ac22529 commit f09a82c
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 139 deletions.
6 changes: 1 addition & 5 deletions fastn-core/src/commands/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,7 @@ fn section(input: &mut String) -> Option<Section> {
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()
);
}
Expand Down
4 changes: 2 additions & 2 deletions fastn-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!("<style>{}</style>", generated_style),
_ => "".to_string(),
};
}
}

pub(crate) async fn download_fonts(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fn extract_type_data(
}

fn extract_raw_data(property_value: Option<fastn_resolved::PropertyValue>) -> Option<ValueType> {
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(),
Expand Down Expand Up @@ -295,7 +295,7 @@ fn extract_raw_data(property_value: Option<fastn_resolved::PropertyValue>) -> Op
Some(fastn_resolved::PropertyValue::Clone { .. }) => None,
Some(fastn_resolved::PropertyValue::FunctionCall { .. }) => None,
None => None,
};
}
}

#[derive(Debug, Default, Serialize, Deserialize)]
Expand Down
4 changes: 2 additions & 2 deletions fastn-core/src/package/redirects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ pub fn find_redirect<'a>(redirects: &'a ftd::Map<String>, 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)]
Expand Down
3 changes: 2 additions & 1 deletion fastn-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ pub struct Timer<'a> {
msg: &'a str,
}

impl<'a> Timer<'a> {
impl Timer<'_> {
pub fn it<T>(&self, a: T) -> T {
use colored::Colorize;

Expand Down Expand Up @@ -607,6 +607,7 @@ async fn get_extra_js(
)
}

#[expect(unused)]
async fn get_extra_css(
config: &fastn_core::Config,
external_css: &[String],
Expand Down
28 changes: 14 additions & 14 deletions fastn-resolved/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ pub type Map<T> = std::collections::BTreeMap<String, T>;

#[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 {
Expand Down Expand Up @@ -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(),
}
}

Expand All @@ -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,
}
}

Expand Down
1 change: 1 addition & 0 deletions fastn-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ homepage.workspace = true

[features]
owned-tdoc = ["fastn-resolved/owned-tdoc"]
default = ["owned-tdoc"]

[dependencies]
fastn-js.workspace = true
Expand Down
30 changes: 6 additions & 24 deletions v0.5/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions v0.5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 5 additions & 10 deletions v0.5/fastn-compiler/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) struct Compiler {
/// checkout resolve_document for why this is an Option
content: Option<Vec<fastn_unresolved::URCI>>,
pub(crate) document: fastn_unresolved::Document,
auto_import_scope: fastn_unresolved::SFId,
// auto_import_scope: fastn_unresolved::SFId,
}

impl Compiler {
Expand All @@ -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![];
Expand All @@ -37,7 +36,6 @@ impl Compiler {
content,
document,
definitions_used: Default::default(),
auto_import_scope,
}
}

Expand All @@ -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.
Expand Down Expand Up @@ -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<fastn_resolved::CompiledDocument, fastn_compiler::Error> {
Compiler::new(symbols, source, package, module, auto_import_scope, arena)
Compiler::new(symbols, source, package, module, arena)
.compile()
.await
}
Expand Down
4 changes: 2 additions & 2 deletions v0.5/fastn-compiler/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ pub trait SymbolStore {
&mut self,
arena: &mut fastn_unresolved::Arena,
symbols: &std::collections::HashSet<fastn_unresolved::Symbol>,
auto_imports: fastn_unresolved::SFId,
);
// auto_imports: fastn_unresolved::SFId,
) -> Vec<fastn_unresolved::URD>;
}
4 changes: 2 additions & 2 deletions v0.5/fastn-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Redirect>,
dynamic_routes: Vec<DynamicRoute>,
}

pub struct AutoImport {}
// pub struct AutoImport {}
pub struct DynamicRoute {}
pub struct Redirect {}
pub struct Sitemap {}
16 changes: 8 additions & 8 deletions v0.5/fastn-core/src/config/read.rs
Original file line number Diff line number Diff line change
@@ -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<Self, ReadError> {
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![],
})
Expand All @@ -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")
// }
6 changes: 3 additions & 3 deletions v0.5/fastn-section/src/parser/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
})
}

Expand Down
1 change: 0 additions & 1 deletion v0.5/fastn-unresolved/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading

0 comments on commit f09a82c

Please sign in to comment.