-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes missing error when using trait constraint. (#5882)
## Description When using trait constraints a blanket implementation is added for the trait constraint generic parameter. This changes avoid the generation of other implementations from the type parameter generic implementation. Fixes #5873 ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers.
- Loading branch information
Showing
13 changed files
with
113 additions
and
10 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
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
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
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
13 changes: 13 additions & 0 deletions
13
test/src/e2e_vm_tests/test_programs/should_fail/struct_generic_abi_encode/Forc.lock
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,13 @@ | ||
[[package]] | ||
name = "core" | ||
source = "path+from-root-379FCEFFEC451D4E" | ||
|
||
[[package]] | ||
name = "std" | ||
source = "path+from-root-379FCEFFEC451D4E" | ||
dependencies = ["core"] | ||
|
||
[[package]] | ||
name = "struct_generic_abi_encode" | ||
source = "member" | ||
dependencies = ["std"] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_fail/struct_generic_abi_encode/Forc.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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
license = "Apache-2.0" | ||
name = "struct_generic_abi_encode" | ||
entry = "main.sw" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../sway-lib-std" } |
1 change: 1 addition & 0 deletions
1
...src/e2e_vm_tests/test_programs/should_fail/struct_generic_abi_encode/json_abi_oracle.json
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 @@ | ||
[] |
33 changes: 33 additions & 0 deletions
33
test/src/e2e_vm_tests/test_programs/should_fail/struct_generic_abi_encode/src/main.sw
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,33 @@ | ||
script; | ||
|
||
#[allow(dead_code)] | ||
struct SomeStruct<T> { | ||
ptr: raw_ptr, | ||
cap: u64, | ||
} | ||
|
||
trait AbiEncode2 { | ||
fn abi_encode2(self, ref mut buffer: Buffer); | ||
} | ||
|
||
|
||
impl AbiEncode2 for u64 | ||
{ | ||
fn abi_encode2(self, ref mut buffer: Buffer) { | ||
|
||
} | ||
} | ||
|
||
impl<T> AbiEncode2 for SomeStruct<T> where T: AbiEncode2 | ||
{ | ||
#[allow(dead_code)] | ||
fn abi_encode2(self, ref mut buffer: Buffer) { | ||
self.ptr.abi_encode2(buffer); | ||
self.cap.abi_encode2(buffer); | ||
} | ||
} | ||
|
||
|
||
fn main() { | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
test/src/e2e_vm_tests/test_programs/should_fail/struct_generic_abi_encode/test.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,4 @@ | ||
category = "fail" | ||
|
||
#check: $()self.ptr.abi_encode2(buffer); | ||
#nextln: $()No method named "abi_encode2" found for type "pointer". |