Skip to content

derive(Format): Support more than 256 variants#302

Merged
bors[bot] merged 1 commit intoknurling-rs:mainfrom
Sh3Rm4n:enum
Dec 16, 2020
Merged

derive(Format): Support more than 256 variants#302
bors[bot] merged 1 commit intoknurling-rs:mainfrom
Sh3Rm4n:enum

Conversation

@Sh3Rm4n
Copy link
Copy Markdown
Contributor

@Sh3Rm4n Sh3Rm4n commented Dec 15, 2020

Closes #63

Copy link
Copy Markdown
Member

@japaric japaric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The encoder part looks good but I think we also need to do changes in the decoder.

Could you add the EnumLarge as a test to firmware/log.rs and test out a small enum and a large (>256) enum?

Comment thread firmware/qemu/src/bin/log.rs Outdated
}

defmt::info!("Format EnumLarge Variant: {:?}", EnumLarge::A007);
defmt::info!("Format EnumLarge Variant: {:?}", EnumLarge::A269);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fails locally with

0.000101 INFO Format EnumLarge Variant: A007
failed to decode defmt data: [0, 99, 1]
Error: malformed data

I think the decoder expects that the discriminant is encoded as a single byte but with these changes it should consider how many the variants the enum has (and use 1,2,3,4,etc. bytes as the discriminant size)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops interesting. It's failing locally for me as well. I just pushed it to have a failing case to move along and eventually make it pass.

But that this does not fail in CI is interesting.

Copy link
Copy Markdown
Member

@japaric japaric Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think CI is not running because the PR has merge conflicts. The last CI run (I'm referring to the GitHub Action runs on this repo; if you are referring to the ones on you fork, I've not seen those) is from your very first version, which didn't have the qemu test.

@Sh3Rm4n Sh3Rm4n force-pushed the enum branch 2 times, most recently from ff704da to 2bacbd9 Compare December 15, 2020 22:24
@japaric
Copy link
Copy Markdown
Member

japaric commented Dec 16, 2020

Nice! Thanks for the PR.

bors r+

bors Bot added a commit that referenced this pull request Dec 16, 2020
302: derive(Format): Support more than 256 variants r=japaric a=Sh3Rm4n

Closes #63

Co-authored-by: Sh3Rm4n <f.vioel@googlemail.com>
@bors
Copy link
Copy Markdown
Contributor

bors Bot commented Dec 16, 2020

Build failed:

Comment thread macros/src/lib.rs Outdated
@japaric
Copy link
Copy Markdown
Member

japaric commented Dec 16, 2020

Thanks! (and sorry for the repeated rebase work)

bors r+

@Sh3Rm4n
Copy link
Copy Markdown
Contributor Author

Sh3Rm4n commented Dec 16, 2020

No problem, these were minor anyways. :)

@bors
Copy link
Copy Markdown
Contributor

bors Bot commented Dec 16, 2020

Build succeeded:

@bors bors Bot merged commit 694bf31 into knurling-rs:main Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

derive(Format): support more than 256 variants

2 participants