-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure where clauses propagated to trait default definitions (#4894
) # Description ## Problem\* Resolves #4847 ## Summary\* Before this PR, we were simply copying the default definition as an unresolved `impl` method, without adding in any `where` clauses from the top level of the `impl`. This PR propagates the `where` clauses into default definitions when they're used. For example: ```rust impl<T> Foo for Bar<T> where T: Foo { fn qux(self) -> bool { ^ we want an implicit "where T: Foo" here .. } } ``` ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <jake@aztecprotocol.com>
- Loading branch information
1 parent
9d53496
commit aaac0f6
Showing
4 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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_from_where_impl/Nargo.toml
This file contains 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_from_where_impl" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.27.0" | ||
|
||
[dependencies] |
15 changes: 15 additions & 0 deletions
15
test_programs/compile_success_empty/impl_from_where_impl/src/main.nr
This file contains 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,15 @@ | ||
trait Bar { | ||
fn ok(self) -> Self; | ||
|
||
fn ref_ok(self) -> Self { | ||
self.ok() | ||
} | ||
} | ||
|
||
impl<T> Bar for (T, T) where T: Bar { | ||
fn ok(self) -> Self { | ||
self | ||
} | ||
} | ||
|
||
fn main() {} |