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
10 changes: 9 additions & 1 deletion compiler/noirc_frontend/src/ast/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub enum TraitItem {
},
Type {
name: Ident,
bounds: Vec<TraitBound>,
},
}

Expand Down Expand Up @@ -215,7 +216,14 @@ impl Display for TraitItem {
write!(f, ";")
}
}
TraitItem::Type { name } => write!(f, "type {name};"),
TraitItem::Type { name, bounds } => {
if bounds.is_empty() {
write!(f, "type {name};")
} else {
let bounds = vecmap(bounds, |bound| bound.to_string()).join(" + ");
write!(f, "type {name}: {bounds};")
}
}
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions compiler/noirc_frontend/src/ast/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ pub trait Visitor {
true
}

fn visit_trait_item_type(&mut self, _: &Ident) {}
fn visit_trait_item_type(&mut self, _: &Ident, _: &[TraitBound]) -> bool {
true
}

fn visit_use_tree(&mut self, _: &UseTree) -> bool {
true
Expand Down Expand Up @@ -788,7 +790,13 @@ impl TraitItem {
}
}
}
TraitItem::Type { name } => visitor.visit_trait_item_type(name),
TraitItem::Type { name, bounds } => {
if visitor.visit_trait_item_type(name, bounds) {
for bound in bounds {
bound.accept(visitor);
}
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/noirc_frontend/src/elaborator/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
location,
has_body: false,
trait_constraints: Vec::new(),
extra_trait_constraints: Vec::new(),
type_id: Some(type_id),
trait_id: None,
trait_impl: None,
Expand Down Expand Up @@ -1005,7 +1006,7 @@

/// Compiles the cases and fallback cases for integer and range patterns.
///
/// Integers have an infinite number of constructors, so we specialise the

Check warning on line 1009 in compiler/noirc_frontend/src/elaborator/enums.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (specialise)
/// compilation of integer and range patterns.
fn compile_int_cases(
&mut self,
Expand Down
Loading
Loading