Skip to content
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

ZeroTrie: add Bake, Yoke, and ZeroFrom impls #4021

Merged
merged 4 commits into from
Sep 12, 2023
Merged

Conversation

sffc
Copy link
Member

@sffc sffc commented Sep 11, 2023

Toward #2909

Left #4020 for a follow-up

extern crate std;
test_bake!(
DeriveTest_ZeroTrie_ZeroVec<'static>,
crate::DeriveTest_ZeroTrie_ZeroVec {
Copy link
Member

Choose a reason for hiding this comment

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

wrapping the zerotrie in a struct doesn't add anything to the test, and it complicates it because it now also requires the struct's bake to be stable. I'd also prefer this as a unit test next to the code under test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Please note that these tests are directly based on the ones in utils/zerovec/src/yoke_impls.rs

wrapping the zerotrie in a struct doesn't add anything to the test

It tests that the zerotrie can be used in a struct with derives. Without this test, it's possible that the imps are missing or incomplete. This was a problem in the past which is why we added these tests in the zerovec crate. I think we should err on the side of testing this behavior for any zero-copy data structure.

and it complicates it because it now also requires the struct's bake to be stable

Why? If the bake changes, update the test.

I'd also prefer this as a unit test next to the code under test.

This doesn't catch problems like private fields. Given that this tests external behavior it seems better for this to be in an integration test.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Shane here, this is our standard pattern for testing derive bounds for generic stuff

right: `"zerotrie :: test :: DeriveTest_ZeroTrieSimpleAscii_ZeroVec { _data : zerotrie :: ZeroTrieSimpleAscii { store : zerovec :: ZeroVec :: new () } , }"`', experimental/zerotrie/src/test.rs:46:5
*/
#[test]
#[ignore] // TODO: Fix (see error message above)
Copy link
Member

Choose a reason for hiding this comment

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

we already have ignored bake tests somewhere that are linked to a Rust issue

experimental/zerotrie/tests/derive_test.rs Show resolved Hide resolved
experimental/zerotrie/src/zerotrie.rs Show resolved Hide resolved
@sffc sffc marked this pull request as ready for review September 11, 2023 17:10
@sffc sffc requested a review from a team as a code owner September 11, 2023 17:10
@sffc sffc requested a review from robertbastian September 11, 2023 17:28
Manishearth
Manishearth previously approved these changes Sep 11, 2023
@sffc sffc merged commit 4575402 into unicode-org:main Sep 12, 2023
@sffc sffc deleted the ztrie1 branch September 12, 2023 08:00
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.

3 participants