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
6 changes: 3 additions & 3 deletions compiler/noirc_frontend/src/elaborator/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use crate::{
hir_def::{
expr::{
HirArrayLiteral, HirBinaryOp, HirBlockExpression, HirCallExpression, HirCastExpression,
HirConstructorExpression, HirIdent, HirIfExpression, HirIndexExpression,
HirInfixExpression, HirLambda, HirMemberAccess, HirMethodCallExpression,
HirMethodReference, HirPrefixExpression,
HirConstructorExpression, HirIfExpression, HirIndexExpression, HirInfixExpression,
HirLambda, HirMemberAccess, HirMethodCallExpression, HirMethodReference,
HirPrefixExpression,
},
traits::TraitConstraint,
},
Expand Down
47 changes: 12 additions & 35 deletions compiler/noirc_frontend/src/elaborator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,59 +1,37 @@
#![allow(unused)]
use std::{
collections::{BTreeMap, BTreeSet, HashMap},
collections::{BTreeMap, BTreeSet},
rc::Rc,
};

use crate::{
ast::{
ArrayLiteral, ConstructorExpression, FunctionKind, IfExpression, InfixExpression, Lambda,
TraitItem, UnresolvedTraitConstraint, UnresolvedTypeExpression,
},
ast::{FunctionKind, UnresolvedTraitConstraint},
hir::{
def_collector::{
dc_crate::{
filter_literal_globals, CompilationError, ImplMap, UnresolvedGlobal,
UnresolvedStruct, UnresolvedTrait, UnresolvedTypeAlias,
UnresolvedStruct, UnresolvedTypeAlias,
},
errors::DuplicateType,
},
resolution::{errors::ResolverError, path_resolver::PathResolver, resolver::LambdaContext},
scope::ScopeForest as GenericScopeForest,
type_check::TypeCheckError,
},
hir_def::{
expr::{
HirArrayLiteral, HirBinaryOp, HirBlockExpression, HirCallExpression, HirCastExpression,
HirConstructorExpression, HirIdent, HirIfExpression, HirIndexExpression,
HirInfixExpression, HirLambda, HirMemberAccess, HirMethodCallExpression,
HirMethodReference, HirPrefixExpression,
},
function::Parameters,
stmt::HirLetStatement,
traits::TraitConstraint,
},
hir_def::{expr::HirIdent, function::Parameters, traits::TraitConstraint},
macros_api::{
BlockExpression, CallExpression, CastExpression, Expression, ExpressionKind, HirExpression,
HirLiteral, HirStatement, Ident, IndexExpression, Literal, MemberAccessExpression,
MethodCallExpression, NodeInterner, NoirFunction, NoirStruct, Pattern, PrefixExpression,
SecondaryAttribute, Statement, StatementKind, StructId,
Ident, NodeInterner, NoirFunction, NoirStruct, Pattern, SecondaryAttribute, StructId,
},
node_interner::{DefinitionKind, DependencyId, ExprId, FuncId, StmtId, TraitId, TypeAliasId},
Shared, StructType, Type, TypeVariable,
node_interner::{DefinitionKind, DependencyId, ExprId, FuncId, TraitId, TypeAliasId},
Shared, Type, TypeVariable,
};
use crate::{
ast::{TraitBound, UnresolvedGenerics},
graph::CrateId,
hir::{
def_collector::{
dc_crate::{CollectedItems, DefCollector},
errors::DefCollectorErrorKind,
},
def_collector::{dc_crate::CollectedItems, errors::DefCollectorErrorKind},
def_map::{LocalModuleId, ModuleDefId, ModuleId, MAIN_FUNCTION},
resolution::{
errors::PubPosition,
import::{PathResolution, PathResolutionError},
path_resolver::StandardPathResolver,
errors::PubPosition, import::PathResolution, path_resolver::StandardPathResolver,
},
Context,
},
Expand Down Expand Up @@ -81,9 +59,7 @@ mod types;

use fm::FileId;
use iter_extended::vecmap;
use noirc_arena::Index;
use noirc_errors::{Location, Span};
use regex::Regex;
use rustc_hash::FxHashSet as HashSet;

/// ResolverMetas are tagged onto each definition to track how many times they are used
Expand Down Expand Up @@ -863,6 +839,8 @@ impl<'context> Elaborator<'context> {
module: LocalModuleId,
impls: Vec<(Vec<Ident>, Span, UnresolvedFunctions)>,
) {
self.local_module = module;

for (generics, _, functions) in impls {
self.file = functions.file_id;
let old_generics_length = self.generics.len();
Expand Down Expand Up @@ -913,7 +891,7 @@ impl<'context> Elaborator<'context> {
self.self_type = Some(self_type.clone());
self.current_trait_impl = trait_impl.impl_id;

let mut methods = trait_impl.methods.function_ids();
let methods = trait_impl.methods.function_ids();

self.elaborate_functions(trait_impl.methods);

Expand Down Expand Up @@ -1284,7 +1262,6 @@ impl<'context> Elaborator<'context> {
self.local_module = trait_impl.module_id;

let unresolved_type = &trait_impl.object_type;
let self_type_span = unresolved_type.span;
let old_generics_length = self.generics.len();
self.add_generics(&trait_impl.generics);

Expand Down
4 changes: 1 addition & 3 deletions compiler/noirc_frontend/src/elaborator/scope.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use noirc_errors::Spanned;
use rustc_hash::FxHashMap as HashMap;

use crate::ast::ERROR_IDENT;
use crate::hir::comptime::Value;
use crate::hir::def_map::{LocalModuleId, ModuleId};
use crate::hir::resolution::path_resolver::{PathResolver, StandardPathResolver};
use crate::hir::resolution::resolver::SELF_TYPE_NAME;
Expand All @@ -18,7 +16,7 @@ use crate::{
traits::Trait,
},
macros_api::{Path, StructId},
node_interner::{DefinitionId, TraitId, TypeAliasId},
node_interner::{DefinitionId, TraitId},
Shared, StructType,
};
use crate::{Type, TypeAlias};
Expand Down
10 changes: 2 additions & 8 deletions compiler/noirc_frontend/src/elaborator/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ use noirc_errors::Location;

use crate::{
ast::{FunctionKind, TraitItem, UnresolvedGenerics, UnresolvedTraitConstraint},
hir::{
def_collector::dc_crate::UnresolvedTrait, def_map::ModuleId,
resolution::path_resolver::StandardPathResolver,
},
hir_def::{
function::{FuncMeta, HirFunction},
traits::{TraitConstant, TraitFunction, TraitType},
},
hir::def_collector::dc_crate::UnresolvedTrait,
hir_def::traits::{TraitConstant, TraitFunction, TraitType},
macros_api::{
BlockExpression, FunctionDefinition, FunctionReturnType, Ident, ItemVisibility,
NoirFunction, Param, Pattern, UnresolvedType, Visibility,
Expand Down
14 changes: 5 additions & 9 deletions compiler/noirc_frontend/src/elaborator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ use noirc_errors::{Location, Span};

use crate::{
ast::{
BinaryOpKind, IntegerBitSize, NoirTypeAlias, UnresolvedGenerics, UnresolvedTraitConstraint,
BinaryOpKind, IntegerBitSize, UnresolvedGenerics, UnresolvedTraitConstraint,
UnresolvedTypeExpression,
},
hir::{
def_map::ModuleDefId,
resolution::{
errors::ResolverError,
import::PathResolution,
resolver::{verify_mutable_reference, SELF_TYPE_NAME},
},
type_check::{Source, TypeCheckError},
Expand All @@ -23,17 +22,14 @@ use crate::{
HirPrefixExpression,
},
function::FuncMeta,
traits::{Trait, TraitConstraint},
traits::TraitConstraint,
},
macros_api::{
HirExpression, HirLiteral, HirStatement, Path, PathKind, SecondaryAttribute, Signedness,
UnaryOp, UnresolvedType, UnresolvedTypeData,
},
node_interner::{
DefinitionKind, DependencyId, ExprId, GlobalId, TraitId, TraitImplKind, TraitMethodId,
TypeAliasId,
},
Generics, Shared, StructType, Type, TypeAlias, TypeBinding, TypeVariable, TypeVariableKind,
node_interner::{DefinitionKind, ExprId, GlobalId, TraitId, TraitImplKind, TraitMethodId},
Generics, Type, TypeBinding, TypeVariable, TypeVariableKind,
};

use super::Elaborator;
Expand Down Expand Up @@ -635,7 +631,7 @@ impl<'context> Elaborator<'context> {
rhs_type: &Type,
span: Span,
) -> Type {
let mut unify = |this: &mut Self, expected| {
let unify = |this: &mut Self, expected| {
this.unify(rhs_type, &expected, || TypeCheckError::TypeMismatch {
expr_typ: rhs_type.to_string(),
expected_typ: expected.to_string(),
Expand Down