Merge branch 'main' into drop_specialization

Signed-off-by: J Teeuwissen <jelleteeuwissen@hotmail.nl>
This commit is contained in:
J Teeuwissen 2023-04-26 20:26:37 +02:00 committed by GitHub
commit 7439ee0c8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
229 changed files with 3602 additions and 2412 deletions

View file

@ -1134,7 +1134,7 @@ fn canonicalize_has_clause(
}
#[allow(clippy::too_many_arguments)]
fn can_extension_type<'a>(
fn can_extension_type(
env: &mut Env,
pol: CanPolarity,
scope: &mut Scope,
@ -1142,7 +1142,7 @@ fn can_extension_type<'a>(
introduced_variables: &mut IntroducedVariables,
local_aliases: &mut VecMap<Symbol, Alias>,
references: &mut VecSet<Symbol>,
opt_ext: &Option<&Loc<TypeAnnotation<'a>>>,
opt_ext: &Option<&Loc<TypeAnnotation<'_>>>,
ext_problem_kind: roc_problem::can::ExtensionTypeKind,
) -> (Type, ExtImplicitOpenness) {
fn valid_record_ext_type(typ: &Type) -> bool {
@ -1451,10 +1451,10 @@ fn can_assigned_fields<'a>(
// TODO trim down these arguments!
#[allow(clippy::too_many_arguments)]
fn can_assigned_tuple_elems<'a>(
fn can_assigned_tuple_elems(
env: &mut Env,
pol: CanPolarity,
elems: &&[Loc<TypeAnnotation<'a>>],
elems: &&[Loc<TypeAnnotation<'_>>],
scope: &mut Scope,
var_store: &mut VarStore,
introduced_variables: &mut IntroducedVariables,

View file

@ -85,6 +85,7 @@ macro_rules! map_symbol_to_lowlevel_and_arity {
// these are used internally and not tied to a symbol
LowLevel::Hash => unimplemented!(),
LowLevel::PtrCast => unimplemented!(),
LowLevel::PtrWrite => unimplemented!(),
LowLevel::RefCountInc => unimplemented!(),
LowLevel::RefCountDec => unimplemented!(),
LowLevel::RefCountIsUnique => unimplemented!(),

View file

@ -1050,9 +1050,7 @@ fn canonicalize_value_defs<'a>(
let mut symbol_to_index: Vec<(IdentId, u32)> = Vec::with_capacity(pending_value_defs.len());
for (def_index, pending_def) in pending_value_defs.iter().enumerate() {
let mut new_bindings = BindingsFromPattern::new(pending_def.loc_pattern())
.into_iter()
.peekable();
let mut new_bindings = BindingsFromPattern::new(pending_def.loc_pattern()).peekable();
if new_bindings.peek().is_none() {
env.problem(Problem::NoIdentifiersIntroduced(
@ -1339,8 +1337,8 @@ fn canonicalize_type_defs<'a>(
/// Resolve all pending abilities, to add them to scope.
#[allow(clippy::too_many_arguments)]
fn resolve_abilities<'a>(
env: &mut Env<'a>,
fn resolve_abilities(
env: &mut Env<'_>,
output: &mut Output,
var_store: &mut VarStore,
scope: &mut Scope,
@ -2813,8 +2811,8 @@ fn to_pending_value_def<'a>(
}
/// Make aliases recursive
fn correct_mutual_recursive_type_alias<'a>(
env: &mut Env<'a>,
fn correct_mutual_recursive_type_alias(
env: &mut Env<'_>,
original_aliases: VecMap<Symbol, Alias>,
var_store: &mut VarStore,
) -> VecMap<Symbol, Alias> {
@ -3022,8 +3020,8 @@ fn correct_mutual_recursive_type_alias<'a>(
unsafe { VecMap::zip(symbols_introduced, aliases) }
}
fn make_tag_union_of_alias_recursive<'a>(
env: &mut Env<'a>,
fn make_tag_union_of_alias_recursive(
env: &mut Env<'_>,
alias_name: Symbol,
alias: &mut Alias,
others: Vec<Symbol>,
@ -3215,8 +3213,8 @@ fn make_tag_union_recursive_help<'a, 'b>(
}
}
fn mark_cyclic_alias<'a>(
env: &mut Env<'a>,
fn mark_cyclic_alias(
env: &mut Env<'_>,
typ: &mut Type,
symbol: Symbol,
alias_kind: AliasKind,

View file

@ -1378,31 +1378,31 @@ pub fn canonicalize_expr<'a>(
// Below this point, we shouln't see any of these nodes anymore because
// operator desugaring should have removed them!
bad_expr @ ast::Expr::ParensAround(_) => {
panic!(
internal_error!(
"A ParensAround did not get removed during operator desugaring somehow: {:#?}",
bad_expr
);
}
bad_expr @ ast::Expr::SpaceBefore(_, _) => {
panic!(
internal_error!(
"A SpaceBefore did not get removed during operator desugaring somehow: {:#?}",
bad_expr
);
}
bad_expr @ ast::Expr::SpaceAfter(_, _) => {
panic!(
internal_error!(
"A SpaceAfter did not get removed during operator desugaring somehow: {:#?}",
bad_expr
);
}
bad_expr @ ast::Expr::BinOps { .. } => {
panic!(
internal_error!(
"A binary operator chain did not get desugared somehow: {:#?}",
bad_expr
);
}
bad_expr @ ast::Expr::UnaryOp(_, _) => {
panic!(
internal_error!(
"A unary operator did not get desugared somehow: {:#?}",
bad_expr
);
@ -1814,7 +1814,7 @@ fn canonicalize_field<'a>(
// A label with no value, e.g. `{ name }` (this is sugar for { name: name })
LabelOnly(_) => {
panic!("Somehow a LabelOnly record field was not desugared!");
internal_error!("Somehow a LabelOnly record field was not desugared!");
}
SpaceBefore(sub_field, _) | SpaceAfter(sub_field, _) => {
@ -1822,7 +1822,7 @@ fn canonicalize_field<'a>(
}
Malformed(_string) => {
panic!("TODO canonicalize malformed record field");
internal_error!("TODO canonicalize malformed record field");
}
}
}

View file

@ -195,11 +195,11 @@ enum GeneratedInfo {
}
impl GeneratedInfo {
fn from_header_type<'a>(
fn from_header_type(
env: &mut Env,
scope: &mut Scope,
var_store: &mut VarStore,
header_type: &HeaderType<'a>,
header_type: &HeaderType<'_>,
) -> Self {
match header_type {
HeaderType::Hosted {
@ -338,7 +338,7 @@ pub fn canonicalize_module_defs<'a>(
can_exposed_imports.insert(symbol, region);
}
Err((_shadowed_symbol, _region)) => {
panic!("TODO gracefully handle shadowing in imports.")
internal_error!("TODO gracefully handle shadowing in imports.")
}
}
} else {
@ -359,7 +359,7 @@ pub fn canonicalize_module_defs<'a>(
// here we do nothing special
}
Err((shadowed_symbol, _region)) => {
panic!(
internal_error!(
"TODO gracefully handle shadowing in imports, {:?} is shadowed.",
shadowed_symbol
)
@ -523,7 +523,7 @@ pub fn canonicalize_module_defs<'a>(
GeneratedInfo::Builtin => {
match crate::builtins::builtin_defs_map(*symbol, var_store) {
None => {
panic!("A builtin module contains a signature without implementation for {:?}", symbol)
internal_error!("A builtin module contains a signature without implementation for {:?}", symbol)
}
Some(replacement_def) => {
declarations.update_builtin_def(index, replacement_def);
@ -581,7 +581,7 @@ pub fn canonicalize_module_defs<'a>(
GeneratedInfo::Builtin => {
match crate::builtins::builtin_defs_map(*symbol, var_store) {
None => {
panic!("A builtin module contains a signature without implementation for {:?}", symbol)
internal_error!("A builtin module contains a signature without implementation for {:?}", symbol)
}
Some(replacement_def) => {
declarations.update_builtin_def(index, replacement_def);

View file

@ -2,6 +2,7 @@
use bumpalo::collections::Vec;
use bumpalo::Bump;
use roc_error_macros::internal_error;
use roc_module::called_via::BinOp::Pizza;
use roc_module::called_via::{BinOp, CalledVia};
use roc_module::ident::ModuleName;
@ -592,7 +593,7 @@ fn binop_step<'a>(
//
// By design, Roc neither allows custom operators nor has any built-in operators with
// the same precedence and different associativity, so this should never happen!
panic!("BinOps had the same associativity, but different precedence. This should never happen!");
internal_error!("BinOps had the same associativity, but different precedence. This should never happen!");
}
}
}

View file

@ -321,8 +321,8 @@ pub fn canonicalize_def_header_pattern<'a>(
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct PermitShadows(pub bool);
fn canonicalize_pattern_symbol<'a>(
env: &mut Env<'a>,
fn canonicalize_pattern_symbol(
env: &mut Env<'_>,
scope: &mut Scope,
output: &mut Output,
region: Region,

View file

@ -1,4 +1,5 @@
use roc_collections::{VecMap, VecSet};
use roc_error_macros::internal_error;
use roc_module::ident::Ident;
use roc_module::symbol::{IdentId, IdentIds, ModuleId, Symbol};
use roc_problem::can::RuntimeError;
@ -470,9 +471,13 @@ pub fn create_alias(
}
if !hidden.is_empty() {
panic!(
internal_error!(
"Found unbound type variables {:?} \n in type alias {:?} {:?} {:?} : {:?}",
hidden, name, &vars, &infer_ext_in_output_variables, &typ
hidden,
name,
&vars,
&infer_ext_in_output_variables,
&typ
)
}

View file

@ -1,6 +1,7 @@
// use bumpalo::collections::string::String;
// use bumpalo::collections::vec::Vec;
use bumpalo::Bump;
use roc_error_macros::internal_error;
use roc_parse::ast::Expr;
// use roc_parse::ast::{Attempting, Expr};
// use roc_parse::ident;
@ -12,7 +13,7 @@ use roc_region::all::Region;
// use std::iter::Peekable;
pub fn canonical_string_literal<'a>(_arena: &Bump, _raw: &'a str, _region: Region) -> Expr<'a> {
panic!("TODO restore canonicalization");
internal_error!("TODO restore canonicalization");
}
// let mut problems = std::vec::Vec::new();

View file

@ -122,7 +122,7 @@ pub fn walk_decls<V: Visitor>(visitor: &mut V, decls: &Declarations) {
None => Pattern::Identifier(loc_symbol.value),
};
let function_def = &decls.function_bodies[function_index.index() as usize];
let function_def = &decls.function_bodies[function_index.index()];
DeclarationInfo::Function {
loc_symbol,
@ -133,7 +133,7 @@ pub fn walk_decls<V: Visitor>(visitor: &mut V, decls: &Declarations) {
}
}
Destructure(destructure_index) => {
let destructure = &decls.destructs[destructure_index.index() as usize];
let destructure = &decls.destructs[destructure_index.index()];
let loc_pattern = &destructure.loc_pattern;
let loc_expr = &decls.expressions[index];