Skip to content

Commit

Permalink
No need for special code to handle where Self: ...
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Oct 23, 2024
1 parent 96adc64 commit f71252c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
9 changes: 0 additions & 9 deletions compiler/noirc_frontend/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,6 @@ impl UnresolvedType {
let typ = UnresolvedTypeData::Named(path, generic_type_args, true);
UnresolvedType { typ, span }
}

pub fn is_self_type(&self) -> bool {
if let UnresolvedTypeData::Named(path, generic_type_args, _) = &self.typ {
generic_type_args.is_empty()
&& path.as_ident().map_or(false, |ident| ident.is_self_type_name())
} else {
false
}
}
}

impl UnresolvedTypeData {
Expand Down
13 changes: 1 addition & 12 deletions compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,20 +379,9 @@ impl<'a> ModCollector<'a> {
let mut errors: Vec<(CompilationError, FileId)> = vec![];
for trait_definition in traits {
let doc_comments = trait_definition.doc_comments;
let mut trait_definition = trait_definition.item;
let trait_definition = trait_definition.item;
let name = trait_definition.name.clone();

// Any where clause that is "Self: Constraint" is the same as a parent constraint,
// so we move those to the parent constraints.
trait_definition.where_clause.retain(|constraint| {
if constraint.typ.is_self_type() {
trait_definition.bounds.push(constraint.trait_bound.clone());
false
} else {
true
}
});

// Create the corresponding module for the trait namespace
let trait_id = match self.push_child_module(
context,
Expand Down

0 comments on commit f71252c

Please sign in to comment.