Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(traits): multi module support for traits #2844

Merged
merged 18 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
11 changes: 5 additions & 6 deletions compiler/noirc_frontend/src/ast/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use noirc_errors::Span;

use crate::{
node_interner::TraitId, BlockExpression, Expression, FunctionReturnType, Ident, NoirFunction,
UnresolvedGenerics, UnresolvedType,
Path, UnresolvedGenerics, UnresolvedType,
};

/// AST node for trait definitions:
Expand Down Expand Up @@ -57,11 +57,10 @@ pub struct TypeImpl {
pub struct NoirTraitImpl {
pub impl_generics: UnresolvedGenerics,

pub trait_name: Ident,
pub trait_name: Path,
pub trait_generics: Vec<UnresolvedType>,

pub object_type: UnresolvedType,
pub object_type_span: Span,

pub where_clause: Vec<UnresolvedTraitConstraint>,

Expand All @@ -83,7 +82,7 @@ pub struct UnresolvedTraitConstraint {
/// Represents a single trait bound, such as `TraitX` or `TraitY<U, V>`
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TraitBound {
pub trait_name: Ident,
pub trait_path: Path,
pub trait_id: Option<TraitId>, // initially None, gets assigned during DC
pub trait_generics: Vec<UnresolvedType>,
}
Expand Down Expand Up @@ -178,9 +177,9 @@ impl Display for TraitBound {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let generics = vecmap(&self.trait_generics, |generic| generic.to_string());
if !generics.is_empty() {
write!(f, "{}<{}>", self.trait_name, generics.join(", "))
write!(f, "{}<{}>", self.trait_path, generics.join(", "))
} else {
write!(f, "{}", self.trait_name)
write!(f, "{}", self.trait_path)
}
}
}
Expand Down
Loading
Loading