fix extra ampersands

This commit is contained in:
Folkert 2021-07-29 17:32:08 +02:00
parent b6116eeb98
commit 899cbeabd7
79 changed files with 372 additions and 376 deletions

View file

@ -64,7 +64,7 @@ impl Constraint {
fn subtract(declared: &Declared, detail: &VariableDetail, accum: &mut VariableDetail) {
for var in &detail.type_variables {
if !(declared.rigid_vars.contains(&var) || declared.flex_vars.contains(&var)) {
if !(declared.rigid_vars.contains(var) || declared.flex_vars.contains(var)) {
accum.type_variables.insert(*var);
}
}
@ -82,11 +82,11 @@ fn subtract(declared: &Declared, detail: &VariableDetail, accum: &mut VariableDe
// recursion vars should be always rigid
for var in &detail.recursion_variables {
if declared.flex_vars.contains(&var) {
if declared.flex_vars.contains(var) {
panic!("recursion variable {:?} is declared as flex", var);
}
if !declared.rigid_vars.contains(&var) {
if !declared.rigid_vars.contains(var) {
accum.recursion_variables.insert(*var);
}
}

View file

@ -380,7 +380,7 @@ pub fn sort_can_defs(
//
// In the above example, `f` cannot reference `a`, and in the closure
// a call to `f` cannot cycle back to `a`.
let mut loc_succ = local_successors(&references, &env.closures);
let mut loc_succ = local_successors(references, &env.closures);
// if the current symbol is a closure, peek into its body
if let Some(References { lookups, .. }) = env.closures.get(symbol) {
@ -430,7 +430,7 @@ pub fn sort_can_defs(
//
// In the above example, `f` cannot reference `a`, and in the closure
// a call to `f` cannot cycle back to `a`.
let mut loc_succ = local_successors(&references, &env.closures);
let mut loc_succ = local_successors(references, &env.closures);
// if the current symbol is a closure, peek into its body
if let Some(References { lookups, .. }) = env.closures.get(symbol) {
@ -454,7 +454,7 @@ pub fn sort_can_defs(
let direct_successors = |symbol: &Symbol| -> ImSet<Symbol> {
match refs_by_symbol.get(symbol) {
Some((_, references)) => {
let mut loc_succ = local_successors(&references, &env.closures);
let mut loc_succ = local_successors(references, &env.closures);
// NOTE: if the symbol is a closure we DONT look into its body
@ -540,7 +540,7 @@ pub fn sort_can_defs(
),
Some((region, _)) => {
let expr_region =
can_defs_by_symbol.get(&symbol).unwrap().loc_expr.region;
can_defs_by_symbol.get(symbol).unwrap().loc_expr.region;
let entry = CycleEntry {
symbol: *symbol,
@ -662,11 +662,11 @@ fn group_to_declaration(
// for a definition, so every definition is only inserted (thus typechecked and emitted) once
let mut seen_pattern_regions: ImSet<Region> = ImSet::default();
for cycle in strongly_connected_components(&group, filtered_successors) {
for cycle in strongly_connected_components(group, filtered_successors) {
if cycle.len() == 1 {
let symbol = &cycle[0];
if let Some(can_def) = can_defs_by_symbol.get(&symbol) {
if let Some(can_def) = can_defs_by_symbol.get(symbol) {
let mut new_def = can_def.clone();
// Determine recursivity of closures that are not tail-recursive
@ -678,7 +678,7 @@ fn group_to_declaration(
*recursive = closure_recursivity(*symbol, closures);
}
let is_recursive = successors(&symbol).contains(&symbol);
let is_recursive = successors(symbol).contains(symbol);
if !seen_pattern_regions.contains(&new_def.loc_pattern.region) {
if is_recursive {
@ -854,7 +854,7 @@ fn canonicalize_pending_def<'a>(
};
for (_, (symbol, _)) in scope.idents() {
if !vars_by_symbol.contains_key(&symbol) {
if !vars_by_symbol.contains_key(symbol) {
continue;
}
@ -999,7 +999,7 @@ fn canonicalize_pending_def<'a>(
//
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
if let (
&ast::Pattern::Identifier(ref _name),
&ast::Pattern::Identifier(_name),
&Pattern::Identifier(ref defined_symbol),
&Closure {
function_type,
@ -1021,7 +1021,7 @@ fn canonicalize_pending_def<'a>(
// Since everywhere in the code it'll be referred to by its defined name,
// remove its generated name from the closure map. (We'll re-insert it later.)
let references = env.closures.remove(&symbol).unwrap_or_else(|| {
let references = env.closures.remove(symbol).unwrap_or_else(|| {
panic!(
"Tried to remove symbol {:?} from procedures, but it was not found: {:?}",
symbol, env.closures
@ -1065,7 +1065,7 @@ fn canonicalize_pending_def<'a>(
// Store the referenced locals in the refs_by_symbol map, so we can later figure out
// which defined names reference each other.
for (_, (symbol, region)) in scope.idents() {
if !vars_by_symbol.contains_key(&symbol) {
if !vars_by_symbol.contains_key(symbol) {
continue;
}
@ -1111,7 +1111,7 @@ fn canonicalize_pending_def<'a>(
let outer_identifier = env.tailcallable_symbol;
if let (
&ast::Pattern::Identifier(ref _name),
&ast::Pattern::Identifier(_name),
&Pattern::Identifier(ref defined_symbol),
) = (&loc_pattern.value, &loc_can_pattern.value)
{
@ -1144,7 +1144,7 @@ fn canonicalize_pending_def<'a>(
//
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
if let (
&ast::Pattern::Identifier(ref _name),
&ast::Pattern::Identifier(_name),
&Pattern::Identifier(ref defined_symbol),
&Closure {
function_type,
@ -1166,7 +1166,7 @@ fn canonicalize_pending_def<'a>(
// Since everywhere in the code it'll be referred to by its defined name,
// remove its generated name from the closure map. (We'll re-insert it later.)
let references = env.closures.remove(&symbol).unwrap_or_else(|| {
let references = env.closures.remove(symbol).unwrap_or_else(|| {
panic!(
"Tried to remove symbol {:?} from procedures, but it was not found: {:?}",
symbol, env.closures
@ -1555,7 +1555,7 @@ fn correct_mutual_recursive_type_alias<'a>(
let mut loc_succ = alias.typ.symbols();
// remove anything that is not defined in the current block
loc_succ.retain(|key| symbols_introduced.contains(key));
loc_succ.remove(&symbol);
loc_succ.remove(symbol);
loc_succ
}

View file

@ -980,7 +980,7 @@ where
visited.insert(defined_symbol);
for local in refs.lookups.iter() {
if !visited.contains(&local) {
if !visited.contains(local) {
let other_refs: References =
references_from_local(*local, visited, refs_by_def, closures);
@ -991,7 +991,7 @@ where
}
for call in refs.calls.iter() {
if !visited.contains(&call) {
if !visited.contains(call) {
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
answer = answer.union(other_refs);
@ -1022,7 +1022,7 @@ where
visited.insert(call_symbol);
for closed_over_local in references.lookups.iter() {
if !visited.contains(&closed_over_local) {
if !visited.contains(closed_over_local) {
let other_refs =
references_from_local(*closed_over_local, visited, refs_by_def, closures);
@ -1033,7 +1033,7 @@ where
}
for call in references.calls.iter() {
if !visited.contains(&call) {
if !visited.contains(call) {
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
answer = answer.union(other_refs);

View file

@ -276,7 +276,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
})
}
When(loc_cond_expr, branches) => {
let loc_desugared_cond = &*arena.alloc(desugar_expr(arena, &loc_cond_expr));
let loc_desugared_cond = &*arena.alloc(desugar_expr(arena, loc_cond_expr));
let mut desugared_branches = Vec::with_capacity_in(branches.len(), arena);
for branch in branches.iter() {
@ -346,7 +346,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
}
If(if_thens, final_else_branch) => {
// If does not get desugared into `when` so we can give more targeted error messages during type checking.
let desugared_final_else = &*arena.alloc(desugar_expr(arena, &final_else_branch));
let desugared_final_else = &*arena.alloc(desugar_expr(arena, final_else_branch));
let mut desugared_if_thens = Vec::with_capacity_in(if_thens.len(), arena);
@ -363,8 +363,8 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
})
}
Expect(condition, continuation) => {
let desugared_condition = &*arena.alloc(desugar_expr(arena, &condition));
let desugared_continuation = &*arena.alloc(desugar_expr(arena, &continuation));
let desugared_condition = &*arena.alloc(desugar_expr(arena, condition));
let desugared_continuation = &*arena.alloc(desugar_expr(arena, continuation));
arena.alloc(Located {
value: Expect(desugared_condition, desugared_continuation),
region: loc_expr.region,

View file

@ -185,7 +185,7 @@ pub fn canonicalize_pattern<'a>(
}
}
FloatLiteral(ref string) => match pattern_type {
FloatLiteral(string) => match pattern_type {
WhenBranch => match finish_parsing_float(string) {
Err(_error) => {
let problem = MalformedPatternProblem::MalformedFloat;

View file

@ -124,7 +124,7 @@ impl Scope {
// If this IdentId was already added previously
// when the value was exposed in the module header,
// use that existing IdentId. Otherwise, create a fresh one.
let ident_id = match exposed_ident_ids.get_id(&ident.as_inline_str()) {
let ident_id = match exposed_ident_ids.get_id(ident.as_inline_str()) {
Some(ident_id) => *ident_id,
None => all_ident_ids.add(ident.clone().into()),
};