Skip to content

Commit c7dcda4

Browse files
authored
chore: use push_err more in elaborator (#5336)
# Description ## Problem\* Resolves <!-- Link to GitHub Issue --> ## Summary\* Quick PR to make more use of the `push_err` helper when creating errors in the elaborator. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
1 parent c44e2b9 commit c7dcda4

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

compiler/noirc_frontend/src/elaborator/mod.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,11 @@ impl<'context> Elaborator<'context> {
484484
self.resolve_type(typ.clone())
485485
};
486486
if !matches!(typ, Type::FieldElement | Type::Integer(_, _)) {
487-
let unsupported_typ_err =
488-
CompilationError::ResolverError(ResolverError::UnsupportedNumericGenericType {
489-
ident: ident.clone(),
490-
typ: typ.clone(),
491-
});
492-
self.errors.push((unsupported_typ_err, self.file));
487+
let unsupported_typ_err = ResolverError::UnsupportedNumericGenericType {
488+
ident: ident.clone(),
489+
typ: typ.clone(),
490+
};
491+
self.push_err(unsupported_typ_err);
493492
}
494493
Kind::Numeric(Box::new(typ))
495494
} else {
@@ -788,12 +787,7 @@ impl<'context> Elaborator<'context> {
788787
let definition = DefinitionKind::GenericType(type_variable);
789788
self.add_variable_decl_inner(ident.clone(), false, false, false, definition);
790789

791-
self.errors.push((
792-
CompilationError::ResolverError(ResolverError::UseExplicitNumericGeneric {
793-
ident,
794-
}),
795-
self.file,
796-
));
790+
self.push_err(ResolverError::UseExplicitNumericGeneric { ident });
797791
}
798792
}
799793
}

compiler/noirc_frontend/src/elaborator/types.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::{
1111
},
1212
hir::{
1313
comptime::{Interpreter, Value},
14-
def_collector::dc_crate::CompilationError,
1514
def_map::ModuleDefId,
1615
resolution::{
1716
errors::ResolverError,
@@ -170,12 +169,11 @@ impl<'context> Elaborator<'context> {
170169
// }
171170
if let Type::NamedGeneric(_, name, resolved_kind) = &resolved_type {
172171
if matches!(resolved_kind, Kind::Numeric { .. }) && matches!(kind, Kind::Normal) {
173-
let expected_typ_err =
174-
CompilationError::ResolverError(ResolverError::NumericGenericUsedForType {
175-
name: name.to_string(),
176-
span: span.expect("Type should have span"),
177-
});
178-
self.errors.push((expected_typ_err, self.file));
172+
let expected_typ_err = ResolverError::NumericGenericUsedForType {
173+
name: name.to_string(),
174+
span: span.expect("Type should have span"),
175+
};
176+
self.push_err(expected_typ_err);
179177
return Type::Error;
180178
}
181179
}

0 commit comments

Comments
 (0)