Skip to content

Commit

Permalink
remove option
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvitkov committed Sep 25, 2023
1 parent a8093b5 commit 3e59eca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/resolution/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ impl<'a> Resolver<'a> {
) -> Vec<TraitConstraint> {
vecmap(where_clause, |constraint| TraitConstraint {
typ: self.resolve_type(constraint.typ.clone()),
trait_id: constraint.trait_bound.trait_id,
trait_id: constraint.trait_bound.trait_id.unwrap_or(TraitId::dummy_id()),
})
}

Expand Down
25 changes: 12 additions & 13 deletions compiler/noirc_frontend/src/hir/type_check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,19 +858,18 @@ impl<'interner> TypeChecker<'interner> {
);

for constraint in func_meta.trait_constraints {
if let Some(trait_id) = constraint.trait_id {
// TODO(#2568): == on types is sketchy, since Field != TypeVar::Bound(Field)
// unify() is sketchier here though, since it may accidentally commit typebindings.
// this works for now, but likely needs to be revisited when we implement generic traits
if *object_type == constraint.typ {
let the_trait = self.interner.get_trait(trait_id);
let the_trait = the_trait.borrow();

for (method_index, method) in the_trait.methods.iter().enumerate() {
if method.name.0.contents == method_name {
let trait_method = TraitMethodId { trait_id, method_index };
return Some(HirMethodReference::TraitMethodId(trait_method));
}
// TODO(#2568): == on types is sketchy, since Field != TypeVar::Bound(Field)
// unify() is sketchier here though, since it may accidentally commit typebindings.

Check warning on line 862 in compiler/noirc_frontend/src/hir/type_check/expr.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (typebindings)
// this works for now, but likely needs to be revisited when we implement generic traits
if *object_type == constraint.typ {
let the_trait = self.interner.get_trait(constraint.trait_id);
let the_trait = the_trait.borrow();

for (method_index, method) in the_trait.methods.iter().enumerate() {
if method.name.0.contents == method_name {
let trait_method =
TraitMethodId { trait_id: constraint.trait_id, method_index };
return Some(HirMethodReference::TraitMethodId(trait_method));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir_def/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub struct TraitImpl {
#[derive(Debug, Clone)]
pub struct TraitConstraint {
pub typ: Type,
pub trait_id: Option<TraitId>,
pub trait_id: TraitId,
// pub trait_generics: Generics, TODO
}

Expand Down

0 comments on commit 3e59eca

Please sign in to comment.