chore: clear remaining clippy warnings
Four small cleanups, no semantic change. Workspace is now clippy- clean (default lints): - ailang-check: collapse `if-same-then-else` for primitive vs ADT type lookup into one branch via a local boolean. - ailang-codegen: iterate `all_strings.values()` directly instead of `for (_mname, entries) in &all_strings`. - ailang-codegen: drop `import_map` parameter from `collect_captures` — was threaded speculatively through every recursive call but never read. - ailang-codegen: `s.len()` instead of `s.as_bytes().len()` in c_byte_len (the warning predates Iter 6). Tests: 52 still green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -475,9 +475,8 @@ fn check_type_def(td: &TypeDef, env: &Env) -> Result<()> {
|
||||
fn check_type_well_formed(t: &Type, env: &Env) -> Result<()> {
|
||||
match t {
|
||||
Type::Con { name } => {
|
||||
if matches!(name.as_str(), "Int" | "Bool" | "Unit" | "Str") {
|
||||
Ok(())
|
||||
} else if env.types.contains_key(name) {
|
||||
let is_primitive = matches!(name.as_str(), "Int" | "Bool" | "Unit" | "Str");
|
||||
if is_primitive || env.types.contains_key(name) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(CheckError::UnknownType(name.clone()))
|
||||
|
||||
@@ -154,7 +154,7 @@ pub fn lower_workspace(ws: &Workspace) -> Result<String> {
|
||||
// Globals: per module, alphabetically over module names (BTreeMap order),
|
||||
// then insertion order per module.
|
||||
let mut emitted_global = false;
|
||||
for (_mname, entries) in &all_strings {
|
||||
for entries in all_strings.values() {
|
||||
for (name, content) in entries {
|
||||
let escaped = ll_string_literal(content);
|
||||
let len = c_byte_len(content);
|
||||
@@ -1086,7 +1086,6 @@ impl<'a> Emitter<'a> {
|
||||
&mut captures_set,
|
||||
&builtins,
|
||||
&top_level,
|
||||
&self.import_map,
|
||||
);
|
||||
|
||||
// Outer scope provides every capture as a local — assert and
|
||||
@@ -1251,7 +1250,6 @@ impl<'a> Emitter<'a> {
|
||||
captures_set: &mut BTreeSet<String>,
|
||||
builtins: &BTreeSet<&str>,
|
||||
top_level: &BTreeSet<String>,
|
||||
import_map: &BTreeMap<String, String>,
|
||||
) {
|
||||
match t {
|
||||
Term::Lit { .. } => {}
|
||||
@@ -1273,36 +1271,36 @@ impl<'a> Emitter<'a> {
|
||||
}
|
||||
}
|
||||
Term::App { callee, args } => {
|
||||
Self::collect_captures(callee, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(callee, bound, captures, captures_set, builtins, top_level);
|
||||
for a in args {
|
||||
Self::collect_captures(a, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(a, bound, captures, captures_set, builtins, top_level);
|
||||
}
|
||||
}
|
||||
Term::Let { name, value, body } => {
|
||||
Self::collect_captures(value, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(value, bound, captures, captures_set, builtins, top_level);
|
||||
let inserted = bound.insert(name.clone());
|
||||
Self::collect_captures(body, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(body, bound, captures, captures_set, builtins, top_level);
|
||||
if inserted {
|
||||
bound.remove(name);
|
||||
}
|
||||
}
|
||||
Term::If { cond, then, else_ } => {
|
||||
Self::collect_captures(cond, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(then, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(else_, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(cond, bound, captures, captures_set, builtins, top_level);
|
||||
Self::collect_captures(then, bound, captures, captures_set, builtins, top_level);
|
||||
Self::collect_captures(else_, bound, captures, captures_set, builtins, top_level);
|
||||
}
|
||||
Term::Do { args, .. } => {
|
||||
for a in args {
|
||||
Self::collect_captures(a, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(a, bound, captures, captures_set, builtins, top_level);
|
||||
}
|
||||
}
|
||||
Term::Ctor { args, .. } => {
|
||||
for a in args {
|
||||
Self::collect_captures(a, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(a, bound, captures, captures_set, builtins, top_level);
|
||||
}
|
||||
}
|
||||
Term::Match { scrutinee, arms } => {
|
||||
Self::collect_captures(scrutinee, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(scrutinee, bound, captures, captures_set, builtins, top_level);
|
||||
for arm in arms {
|
||||
let mut pat_bindings = Vec::new();
|
||||
Self::pattern_bound_names(&arm.pat, &mut pat_bindings);
|
||||
@@ -1312,7 +1310,7 @@ impl<'a> Emitter<'a> {
|
||||
newly_bound.push(n.clone());
|
||||
}
|
||||
}
|
||||
Self::collect_captures(&arm.body, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(&arm.body, bound, captures, captures_set, builtins, top_level);
|
||||
for n in newly_bound {
|
||||
bound.remove(&n);
|
||||
}
|
||||
@@ -1327,14 +1325,14 @@ impl<'a> Emitter<'a> {
|
||||
newly_bound.push(p.clone());
|
||||
}
|
||||
}
|
||||
Self::collect_captures(body, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(body, bound, captures, captures_set, builtins, top_level);
|
||||
for n in newly_bound {
|
||||
bound.remove(&n);
|
||||
}
|
||||
}
|
||||
Term::Seq { lhs, rhs } => {
|
||||
Self::collect_captures(lhs, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(rhs, bound, captures, captures_set, builtins, top_level, import_map);
|
||||
Self::collect_captures(lhs, bound, captures, captures_set, builtins, top_level);
|
||||
Self::collect_captures(rhs, bound, captures, captures_set, builtins, top_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1546,7 +1544,7 @@ fn builtin_binop(name: &str) -> Option<(&'static str, &'static str)> {
|
||||
}
|
||||
|
||||
fn c_byte_len(s: &str) -> usize {
|
||||
s.as_bytes().len() + 1 // + NUL
|
||||
s.len() + 1 // + NUL terminator
|
||||
}
|
||||
|
||||
/// Escapes a string for LLVM IR `c"..."`. All bytes outside
|
||||
|
||||
Reference in New Issue
Block a user