diff --git a/.github/renovate.json b/.github/renovate.json index cacf6919..47adda46 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,20 +1,12 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:best-practices" - ], - "ignoreDeps": [ - "taiki-e/install-action" - ], + "extends": ["config:best-practices"], + "ignoreDeps": ["taiki-e/install-action"], "packageRules": [ { - "matchManagers": [ - "cargo" - ], + "matchManagers": ["cargo"], "groupName": "arborium crates", - "matchPackageNames": [ - "/^arborium-/" - ] + "matchPackageNames": ["/^arborium-/"] } ] } diff --git a/crates/plotnik-lib/src/query/alt_kinds.rs b/crates/plotnik-lib/src/query/alt_kinds.rs index 0f2d31a1..9c6074a6 100644 --- a/crates/plotnik-lib/src/query/alt_kinds.rs +++ b/crates/plotnik-lib/src/query/alt_kinds.rs @@ -55,8 +55,8 @@ impl AltKindsValidator<'_> { let tagged_range = tagged_branch .label() - .map(|t| t.text_range()) - .unwrap_or_else(|| branch_range(tagged_branch)); + .expect("tagged branch found via filter must have label") + .text_range(); let untagged_range = branch_range(untagged_branch); diff --git a/crates/plotnik-lib/src/query/dependencies.rs b/crates/plotnik-lib/src/query/dependencies.rs index c00d8fc8..1bc73481 100644 --- a/crates/plotnik-lib/src/query/dependencies.rs +++ b/crates/plotnik-lib/src/query/dependencies.rs @@ -147,9 +147,10 @@ impl<'a, 'd> RecursionValidator<'a, 'd> { // A component is recursive if it has >1 node, or 1 node that references itself. if scc.len() == 1 { let name = &scc[0]; - let Some(body) = self.symbol_table.get(name) else { - return; - }; + let body = self + .symbol_table + .get(name) + .expect("node in SCC must exist in symbol table"); if !collect_refs(body, self.symbol_table).contains(name.as_str()) { return; } diff --git a/crates/plotnik-lib/src/query/link.rs b/crates/plotnik-lib/src/query/link.rs index f259e05a..2c6b42db 100644 --- a/crates/plotnik-lib/src/query/link.rs +++ b/crates/plotnik-lib/src/query/link.rs @@ -338,7 +338,10 @@ impl<'a, 'q> Linker<'a, 'q> { parent_range: TextRange, ) { let valid_fields = self.lang.fields_for_node_type(parent_id); - let parent_name = self.lang.node_type_name(parent_id).unwrap_or("(unknown)"); + let parent_name = self + .lang + .node_type_name(parent_id) + .expect("validated parent_id must have a name"); let mut builder = self .diagnostics diff --git a/crates/plotnik-lib/src/query/type_check/emit_ts.rs b/crates/plotnik-lib/src/query/type_check/emit_ts.rs index 3f30a4cb..c37e8420 100644 --- a/crates/plotnik-lib/src/query/type_check/emit_ts.rs +++ b/crates/plotnik-lib/src/query/type_check/emit_ts.rs @@ -195,9 +195,10 @@ impl<'a> TsEmitter<'a> { return; } - let Some(kind) = self.ctx.get_type(type_id) else { - return; - }; + let kind = self + .ctx + .get_type(type_id) + .expect("valid TypeId required for naming context"); match kind { TypeKind::Struct(fields) => { @@ -239,9 +240,10 @@ impl<'a> TsEmitter<'a> { return; } - let Some(kind) = self.ctx.get_type(type_id) else { - return; - }; + let kind = self + .ctx + .get_type(type_id) + .expect("valid TypeId required for builtin collection"); match kind { TypeKind::Node | TypeKind::Custom(_) => { @@ -319,9 +321,10 @@ impl<'a> TsEmitter<'a> { return; } - let Some(kind) = self.ctx.get_type(type_id) else { - return; - }; + let kind = self + .ctx + .get_type(type_id) + .expect("valid TypeId required for reachability"); match kind { TypeKind::Struct(fields) => { @@ -340,9 +343,10 @@ impl<'a> TsEmitter<'a> { } fn get_direct_deps(&self, type_id: TypeId) -> Vec { - let Some(kind) = self.ctx.get_type(type_id) else { - return vec![]; - }; + let kind = self + .ctx + .get_type(type_id) + .expect("valid TypeId required for dependency calculation"); match kind { TypeKind::Struct(fields) => fields .values() @@ -362,9 +366,10 @@ impl<'a> TsEmitter<'a> { if type_id.is_builtin() { return vec![]; } - let Some(kind) = self.ctx.get_type(type_id) else { - return vec![]; - }; + let kind = self + .ctx + .get_type(type_id) + .expect("valid TypeId required for unwrapping"); match kind { TypeKind::Array { element, .. } => self.unwrap_for_deps(*element), TypeKind::Optional(inner) => self.unwrap_for_deps(*inner), @@ -389,9 +394,10 @@ impl<'a> TsEmitter<'a> { fn emit_generated_type_def(&mut self, type_id: TypeId, name: &str) { self.emitted.insert(type_id); let export = if self.config.export { "export " } else { "" }; - let Some(kind) = self.ctx.get_type(type_id) else { - return; - }; + let kind = self + .ctx + .get_type(type_id) + .expect("valid TypeId required for generation"); match kind { TypeKind::Struct(fields) => self.emit_interface(name, fields, export), @@ -405,9 +411,10 @@ impl<'a> TsEmitter<'a> { let export = if self.config.export { "export " } else { "" }; let type_name = to_pascal_case(name); - let Some(kind) = self.ctx.get_type(type_id) else { - return; - }; + let kind = self + .ctx + .get_type(type_id) + .expect("valid TypeId required for definition emission"); match kind { TypeKind::Struct(fields) => { @@ -496,9 +503,10 @@ impl<'a> TsEmitter<'a> { _ => {} } - let Some(kind) = self.ctx.get_type(type_id) else { - return "unknown".to_string(); - }; + let kind = self + .ctx + .get_type(type_id) + .expect("valid TypeId required for TS conversion"); match kind { TypeKind::Void => "void".to_string(), @@ -567,9 +575,10 @@ impl<'a> TsEmitter<'a> { } fn inline_data_type(&self, type_id: TypeId) -> String { - let Some(kind) = self.ctx.get_type(type_id) else { - return "unknown".to_string(); - }; + let kind = self + .ctx + .get_type(type_id) + .expect("valid TypeId required for inline data emission"); match kind { TypeKind::Struct(fields) => self.inline_struct(fields), diff --git a/crates/plotnik-lib/src/query/type_check/infer.rs b/crates/plotnik-lib/src/query/type_check/infer.rs index e1390440..4c8cabe5 100644 --- a/crates/plotnik-lib/src/query/type_check/infer.rs +++ b/crates/plotnik-lib/src/query/type_check/infer.rs @@ -498,9 +498,10 @@ impl<'a, 'd> InferenceVisitor<'a, 'd> { return; }; - let Some(fields) = self.ctx.get_struct_fields(*type_id) else { - return; - }; + let fields = self + .ctx + .get_struct_fields(*type_id) + .expect("Bubble flow must point to a Struct type"); if fields.is_empty() { return; }