-
Notifications
You must be signed in to change notification settings - Fork 381
feat(frontend): Where clause on impl #5320
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
63a227f
where clause on impl
vezenovm d835d67
add small docs info on impl where
vezenovm e733bae
remove old comment
vezenovm c326d4c
add impl with where clause to fmt tests
vezenovm 4f55978
Merge branch 'master' into mv/impl-where-clause
vezenovm 4f3fe0c
fmt
vezenovm 51a82df
Update compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs
vezenovm 1c650ce
Update compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs
vezenovm d4da84c
Update docs/docs/noir/concepts/traits.md
vezenovm aa23e15
fixup after suggested changes
vezenovm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test_programs/compile_success_empty/impl_where_clause/Nargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [package] | ||
| name = "impl_where_clause" | ||
| type = "bin" | ||
| authors = [""] | ||
| compiler_version = ">=0.31.0" | ||
|
|
||
| [dependencies] |
34 changes: 34 additions & 0 deletions
34
test_programs/compile_success_empty/impl_where_clause/src/main.nr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| struct MyStruct<T> { | ||
| a: u32, | ||
| b: T, | ||
| } | ||
|
|
||
| struct InnerStruct { | ||
| a: Field, | ||
| b: Field, | ||
| } | ||
|
|
||
| trait MyEq { | ||
| fn my_eq(self, other: Self) -> bool; | ||
| } | ||
|
|
||
| impl MyEq for InnerStruct { | ||
| fn my_eq(self, other: InnerStruct) -> bool { | ||
| (self.a == other.a) & (self.b == other.b) | ||
| } | ||
| } | ||
|
|
||
| impl<T> MyStruct<T> where T: MyEq { | ||
| fn my_eq(self, other: Self) -> bool { | ||
| (self.a == other.a) & self.b.my_eq(other.b) | ||
| } | ||
| } | ||
|
|
||
| fn main() { | ||
| let inner = InnerStruct { a: 1, b: 2 }; | ||
| let my_struct = MyStruct { a: 5, b: inner }; | ||
| assert(my_struct.my_eq(my_struct)); | ||
|
|
||
| let mut my_struct_new = MyStruct { a: 5, b: InnerStruct { a: 10, b: 15 } }; | ||
| assert(my_struct_new.my_eq(my_struct_new)); | ||
| } |
2 changes: 1 addition & 1 deletion
2
...s_empty/impl_with_where_clause/Nargo.toml → ...y/trait_impl_with_where_clause/Nargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| [package] | ||
| name = "impl_with_where_clause" | ||
| name = "trait_impl_with_where_clause" | ||
| type = "bin" | ||
| authors = [""] | ||
|
|
||
|
|
||
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.