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
5 changes: 5 additions & 0 deletions compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ impl ModCollector<'_> {
let has_allow_dead_code =
trait_definition.attributes.iter().any(|attr| attr.kind.is_allow("dead_code"));

desugar_generic_trait_bounds(
&mut trait_definition.generics,
&mut trait_definition.where_clause,
);

// Create the corresponding module for the trait namespace
let trait_id = match self.push_child_module(
context,
Expand Down
21 changes: 21 additions & 0 deletions compiler/noirc_frontend/src/tests/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,27 @@ fn as_trait_path_called_multiple_times_for_different_t_2() {
check_monomorphization_error!(src);
}

#[named]
#[test]
fn short_syntax_for_trait_constraint_on_trait_generic() {
let src = r#"
pub trait Other {
fn other(self) {
let _ = self;
}
}

pub trait Trait<T: Other> {
fn foo(x: T) {
x.other();
}
}

fn main() {}
"#;
check_monomorphization_error!(src);
}

#[named]
#[test]
fn ambiguous_associated_type() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

[package]
name = "noirc_frontend_tests_traits_short_syntax_for_trait_constraint_on_trait_generic"
type = "bin"
authors = [""]

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

pub trait Other {
fn other(self) {
let _ = self;
}
}

pub trait Trait<T: Other> {
fn foo(x: T) {
x.other();
}
}

fn main() {}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12397208803698849218

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading