Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/elaborator/comptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl<'context> Elaborator<'context> {

if &parameters[0] != expected_type {
return Err(InterpreterError::TypeMismatch {
expected: parameters[0].clone(),
expected: parameters[0].to_string(),
actual: expected_type.clone(),
location,
}
Expand Down Expand Up @@ -504,7 +504,7 @@ impl<'context> Elaborator<'context> {
&mut errors,
|| {
CompilationError::InterpreterError(InterpreterError::TypeMismatch {
expected: param_type.clone(),
expected: param_type.to_string(),
actual: expr_type.clone(),
location: arg_location,
})
Expand Down
7 changes: 3 additions & 4 deletions compiler/noirc_frontend/src/elaborator/trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
Kind, NamedGeneric, ResolvedGeneric, Shared, TypeBindings, TypeVariable,
ast::{GenericTypeArgs, Ident, UnresolvedType, UnresolvedTypeData, UnresolvedTypeExpression},
elaborator::{PathResolutionMode, types::bind_ordered_generics},
graph::CrateId,
hir::{
def_collector::{
dc_crate::{CompilationError, UnresolvedTraitImpl},
Expand Down Expand Up @@ -408,12 +407,12 @@ impl Elaborator<'_> {
self.local_module = trait_impl.module_id;

let object_crate = match &trait_impl.resolved_object_type {
Some(Type::DataType(struct_type, _)) => struct_type.borrow().id.krate(),
_ => CrateId::Dummy,
Some(Type::DataType(struct_type, _)) => Some(struct_type.borrow().id.krate()),
_ => None,
};

let the_trait = self.interner.get_trait(trait_id);
if self.crate_id != the_trait.crate_id && self.crate_id != object_crate {
if self.crate_id != the_trait.crate_id && Some(self.crate_id) != object_crate {
self.push_err(DefCollectorErrorKind::TraitImplOrphaned {
location: trait_impl.object_type.location,
});
Expand Down
12 changes: 2 additions & 10 deletions compiler/noirc_frontend/src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,20 @@ pub enum CrateId {
/// In that case there's only one crate, and it's both the root
/// crate and the stdlib crate.
RootAndStdlib(usize),
Dummy,
}

impl CrateId {
pub fn dummy_id() -> CrateId {
CrateId::Dummy
}

pub fn is_stdlib(&self) -> bool {
match self {
CrateId::Stdlib(_) | CrateId::RootAndStdlib(_) => true,
CrateId::Root(_) | CrateId::Crate(_) | CrateId::Dummy => false,
CrateId::Root(_) | CrateId::Crate(_) => false,
}
}

pub fn is_root(&self) -> bool {
match self {
CrateId::Root(_) | CrateId::RootAndStdlib(_) => true,
CrateId::Stdlib(_) | CrateId::Crate(_) | CrateId::Dummy => false,
CrateId::Stdlib(_) | CrateId::Crate(_) => false,
}
}
}
Expand Down Expand Up @@ -251,9 +246,6 @@ impl CrateGraph {
Some((CrateId::Stdlib(_), _)) | Some((CrateId::RootAndStdlib(_), _)) => {
panic!("ICE: Tried to re-add the stdlib crate as a regular crate")
}
Some((CrateId::Dummy, _)) => {
panic!("ICE: A dummy CrateId should not exist in the CrateGraph")
}
None => {
let data = CrateData { root_file_id: file_id, dependencies: Vec::new() };
let crate_id = CrateId::Crate(self.arena.len());
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/comptime/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum InterpreterError {
location: Location,
},
TypeMismatch {
expected: Type,
expected: String,
actual: Type,
location: Location,
},
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/hir/comptime/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ impl<'local, 'interner> Interpreter<'local, 'interner> {
(value, _) => {
let actual = value.get_type().into_owned();
Err(InterpreterError::TypeMismatch {
expected: typ.clone(),
expected: typ.to_string(),
actual,
location,
})
Expand Down Expand Up @@ -524,7 +524,7 @@ impl<'local, 'interner> Interpreter<'local, 'interner> {
Ok(())
}
value => Err(InterpreterError::TypeMismatch {
expected: typ.clone(),
expected: typ.to_string(),
actual: value.get_type().into_owned(),
location,
}),
Expand Down
Loading
Loading