Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/elaborator/comptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl<'context> Elaborator<'context> {
arguments.insert(0, (item, location));

let value = interpreter
.call_function(function, arguments, TypeBindings::new(), location)
.call_function(function, arguments, TypeBindings::default(), location)
.map_err(CompilationError::from)?;

self.debug_comptime(location, |interner| value.display(interner).to_string());
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/elaborator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ impl<'context> Elaborator<'context> {

let impl_trait = the_trait.name.to_string();

let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
bind_ordered_generics(
&the_trait.generics,
&trait_impl.resolved_trait_generics,
Expand Down Expand Up @@ -1455,7 +1455,7 @@ impl<'context> Elaborator<'context> {

let impl_trait = the_trait.name.to_string();

let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
bind_ordered_generics(
&the_trait.generics,
&trait_impl.resolved_trait_generics,
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/elaborator/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ impl Elaborator<'_> {
&& definition.is_some_and(DefinitionInfo::is_comptime_local);
let definition_kind = definition.as_ref().map(|definition| definition.kind.clone());

let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();

// Resolve any generics if we the variable we have resolved is a function
// and if the turbofish operator was used.
Expand Down Expand Up @@ -973,7 +973,7 @@ impl Elaborator<'_> {
expr_id: ExprId,
generics: Option<Vec<Type>>,
) -> Type {
let bindings = TypeBindings::new();
let bindings = TypeBindings::default();
self.type_check_variable_with_bindings(ident, expr_id, generics, bindings)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/elaborator/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ fn check_function_type_matches_expected_type(
trait_name: &str,
errors: &mut Vec<TypeCheckError>,
) {
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
if let (
Type::Function(params_a, ret_a, env_a, unconstrained_a),
Type::Function(params_b, ret_b, env_b, unconstrained_b),
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/elaborator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@
expected: &Type,
make_error: impl FnOnce() -> TypeCheckError,
) {
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
if actual.try_unify(expected, &mut bindings).is_err() {
let error: CompilationError = make_error().into();
self.push_err(error);
Expand Down Expand Up @@ -2172,7 +2172,7 @@
let existing = existing.follow_bindings();
let new = binding.2.follow_bindings();

// Exact equality on types is intential here, we never want to

Check warning on line 2175 in compiler/noirc_frontend/src/elaborator/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (intential)
// overwrite even type variables but should probably avoid a panic if
// the types are exactly the same.
if existing != new {
Expand Down Expand Up @@ -2311,7 +2311,7 @@
trait_bound: &ResolvedTraitBound,
parent_trait_bound: &ResolvedTraitBound,
) -> ResolvedTraitBound {
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
self.bind_generics_from_trait_bound(trait_bound, &mut bindings);
ResolvedTraitBound {
trait_generics: parent_trait_bound.trait_generics.map(|typ| typ.substitute(&bindings)),
Expand Down
3 changes: 1 addition & 2 deletions compiler/noirc_frontend/src/hir/comptime/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![cfg(test)]

use std::collections::HashMap;
use std::path::PathBuf;

use fm::{FileId, FileManager};
Expand Down Expand Up @@ -76,7 +75,7 @@ fn interpret_helper(src: &str) -> Result<Value, InterpreterError> {
with_interpreter(src, |interpreter, main, errors| {
assert_eq!(errors.len(), 0);
let no_location = Location::dummy();
interpreter.call_function(main, Vec::new(), HashMap::new(), no_location)
interpreter.call_function(main, Vec::new(), Default::default(), no_location)
})
}

Expand Down
23 changes: 10 additions & 13 deletions compiler/noirc_frontend/src/hir_def/types.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::{
borrow::Cow,
cell::RefCell,
collections::{BTreeSet, HashMap},
rc::Rc,
};
use std::{borrow::Cow, cell::RefCell, collections::BTreeSet, rc::Rc};

use fxhash::FxHashMap as HashMap;

#[cfg(test)]
use proptest_derive::Arbitrary;
Expand Down Expand Up @@ -243,7 +240,7 @@

// Kind::Numeric unifies along its Type argument
(Kind::Numeric(lhs), Kind::Numeric(rhs)) => {
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
let unifies = lhs.try_unify(rhs, &mut bindings).is_ok();
if unifies {
Type::apply_type_bindings(bindings);
Expand Down Expand Up @@ -1790,7 +1787,7 @@
/// (including try_unify) are almost always preferred over Type::eq as unification
/// will correctly handle generic types.
pub fn unify(&self, expected: &Type) -> Result<(), UnificationError> {
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();

self.try_unify(expected, &mut bindings).map(|()| {
// Commit any type bindings on success
Expand Down Expand Up @@ -2062,7 +2059,7 @@
errors: &mut Vec<TypeCheckError>,
make_error: impl FnOnce() -> TypeCheckError,
) {
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();

if let Ok(()) = self.try_unify(expected, &mut bindings) {
Type::apply_type_bindings(bindings);
Expand Down Expand Up @@ -2134,7 +2131,7 @@
if let Some(as_slice) = interner.lookup_direct_method(&this, "as_slice", true) {
// Still have to ensure the element types match.
// Don't need to issue an error here if not, it will be done in unify_with_coercions
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
if element1.try_unify(element2, &mut bindings).is_ok() {
convert_array_expression_to_slice(expression, this, target, as_slice, interner);
Self::apply_type_bindings(bindings);
Expand All @@ -2155,7 +2152,7 @@
{
// Still have to ensure the element types match.
// Don't need to issue an error here if not, it will be done in unify_with_coercions
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
if this_elem.try_unify(target_elem, &mut bindings).is_ok() {
Self::apply_type_bindings(bindings);
return true;
Expand Down Expand Up @@ -2338,7 +2335,7 @@
let instantiated = typ.force_substitute(&replacements);
(instantiated, replacements)
}
other => (other.clone(), HashMap::new()),
other => (other.clone(), HashMap::default()),
}
}

Expand Down Expand Up @@ -2375,7 +2372,7 @@
let instantiated = typ.substitute(&replacements);
(instantiated, replacements)
}
other => (other.clone(), HashMap::new()),
other => (other.clone(), HashMap::default()),
}
}

Expand Down Expand Up @@ -2431,7 +2428,7 @@
}
};

let substitute_binding = |binding: &TypeVariable| {

Check warning on line 2431 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (recuring)
// Check the id first to allow substituting to
// type variables that have already been bound over.
// This is needed for monomorphizing trait impl methods.
Expand Down Expand Up @@ -2517,7 +2514,7 @@
let typ = Box::new(typ.substitute_helper(type_bindings, substitute_bound_typevars));
Type::Forall(typevars.clone(), typ)
}
Type::Function(args, ret, env, unconstrained) => {

Check warning on line 2517 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (typevarsfined)
let args = vecmap(args, |arg| {
arg.substitute_helper(type_bindings, substitute_bound_typevars)
});
Expand Down Expand Up @@ -2684,7 +2681,7 @@
Type::TypeVariable(var) | Type::NamedGeneric(NamedGeneric { type_var: var, .. }) => {
if let TypeBinding::Bound(typ) = &*var.borrow() {
return Cow::Owned(typ.follow_bindings_shallow().into_owned());
}

Check warning on line 2684 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (typevariable)
Cow::Borrowed(self)
}
Type::Alias(alias_def, generics) => {
Expand All @@ -2709,7 +2706,7 @@
| Type::Integer(_, _)
| Type::Bool
| Type::Unit
| Type::Error

Check warning on line 2709 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (unbindable)
| Type::Quoted(_) => (),

Type::Array(len, elem) => {
Expand Down Expand Up @@ -3255,7 +3252,7 @@
Type::Alias(alias, args) => {
alias.hash(state);
args.hash(state);
}

Check warning on line 3255 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (elems)

Check warning on line 3255 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (elems)
Type::NamedGeneric(NamedGeneric { type_var, implicit: true, .. }) => {
// An implicitly added unbound named generic's hash must be the same as any other
// implicitly added unbound named generic's hash.
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/monomorphization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,7 @@ pub fn perform_impl_bindings(
impl_method: node_interner::FuncId,
location: Location,
) -> Result<TypeBindings, InterpreterError> {
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();

if let Some(trait_method) = trait_method {
let the_trait = interner.get_trait(trait_method.trait_id);
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/node_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@
interned_statement_kinds: noirc_arena::Arena<StatementKind>,

// Interned `UnresolvedTypeData`s during comptime code.
interned_unresolved_type_datas: noirc_arena::Arena<UnresolvedTypeData>,

Check warning on line 221 in compiler/noirc_frontend/src/node_interner.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (datas)

// Interned `Pattern`s during comptime code.
interned_patterns: noirc_arena::Arena<Pattern>,

/// Determins whether to run in LSP mode. In LSP mode references are tracked.

Check warning on line 226 in compiler/noirc_frontend/src/node_interner.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Determins)
pub(crate) lsp_mode: bool,

/// Whether to avoid comptime println from producing output
Expand Down Expand Up @@ -706,7 +706,7 @@
quoted_types: Default::default(),
interned_expression_kinds: Default::default(),
interned_statement_kinds: Default::default(),
interned_unresolved_type_datas: Default::default(),

Check warning on line 709 in compiler/noirc_frontend/src/node_interner.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (datas)
interned_patterns: Default::default(),
lsp_mode: false,
disable_comptime_printing: false,
Expand Down Expand Up @@ -1526,7 +1526,7 @@
trait_generics: &[Type],
trait_associated_types: &[NamedType],
) -> Result<(TraitImplKind, TypeBindings, TypeBindings), ImplSearchErrorKind> {
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
let (impl_kind, instantiation_bindings) = self.lookup_trait_implementation_helper(
object_type,
trait_id,
Expand Down Expand Up @@ -2299,7 +2299,7 @@
trait_impl_generics: &[Type],
impl_self_type: Type,
) -> TypeBindings {
let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
let the_trait = self.get_trait(trait_id);
let trait_generics = the_trait.generics.clone();

Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/src/cli/expand_cmd/printer/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl ItemPrinter<'_, '_, '_> {
let param_type = func_meta.parameters.0[0].1.follow_bindings();
let param_type = if let Type::Reference(typ, ..) = param_type { *typ } else { param_type };

let mut bindings = TypeBindings::new();
let mut bindings = TypeBindings::default();
if self_type.try_unify(&param_type, &mut bindings).is_err() {
return false;
}
Expand Down
Loading