-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error for invalid deku_id generation on generic enum (#411)
Add/Fixup lifetime for generated code for enum ext id finding. Lifetime __deku needs to be added to the deku_id_type, and the impl.
- Loading branch information
1 parent
d6bf743
commit b6a46d5
Showing
5 changed files
with
38 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use deku::prelude::*; | ||
|
||
#[derive(DekuRead)] | ||
#[deku(id_type = "u8")] | ||
pub enum Body<T: for<'a> DekuReader<'a>> { | ||
#[deku(id = "0x0001")] | ||
First(T), | ||
} | ||
|
||
fn main() { | ||
let n = Body::<u8>::First(1); | ||
n.deku_id(); | ||
} |
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,12 @@ | ||
error[E0599]: no method named `deku_id` found for enum `Body` in the current scope | ||
--> tests/test_compile/cases/no_deku_id_generic_enum.rs:12:7 | ||
| | ||
5 | pub enum Body<T: for<'a> DekuReader<'a>> { | ||
| ---------------------------------------- method `deku_id` not found for this enum | ||
... | ||
12 | n.deku_id(); | ||
| ^^^^^^^ method not found in `Body<u8>` | ||
| | ||
= help: items from traits can only be used if the trait is implemented and in scope | ||
= note: the following trait defines an item `deku_id`, perhaps you need to implement it: | ||
candidate #1: `deku::DekuEnumExt` |