Use a shared env for desugaring and the rest of canonicalization

This refactor simplifies the desugar pass by reducing the number of
arguments threaded through each recursive function call.

- Add the module src string to `Env`.
- Add `line_info` to `Env` as a lazy-evaled function.
- Refactor desugar functions to take the `can::Env` struct in place of a
  number of params. This is mostly a find-and-replace, but in a few
  places `Vec::from_iter_in` was changed to `Vec::with_capacity_in`
  followed by a `for` loop in order to avoid lifetime issues.
- Remove unnecessary linter annotations for `clippy::too_many_arguments`
This commit is contained in:
Elias Mulhall 2024-09-03 11:56:07 -04:00
parent 640bd15ca1
commit b515bfa77e
No known key found for this signature in database
GPG key ID: 8D1F3C219EAB45F2
6 changed files with 349 additions and 880 deletions

View file

@ -240,6 +240,7 @@ pub fn canonicalize_module_defs<'a>(
);
let mut env = Env::new(
arena,
src,
home,
arena.alloc(Path::new(module_path)),
dep_idents,
@ -266,16 +267,7 @@ pub fn canonicalize_module_defs<'a>(
// operators, and then again on *their* nested operators, ultimately applying the
// rules multiple times unnecessarily.
crate::desugar::desugar_defs_node_values(
arena,
&mut scope,
loc_defs,
src,
&mut None,
module_path,
true,
&mut env.problems,
);
crate::desugar::desugar_defs_node_values(&mut env, &mut scope, loc_defs, true);
let mut rigid_variables = RigidVariables::default();