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

Implement Bake for VZV types of different formats #5719

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

robertbastian
Copy link
Member

No description provided.

@robertbastian robertbastian requested review from Manishearth, sffc and a team as code owners October 21, 2024 23:14
@@ -291,6 +291,11 @@ pub mod vecs {
pub use crate::varzerovec::{VarZeroSlice, VarZeroVec};

pub use crate::varzerovec::{Index16, Index32, Index8, VarZeroVecFormat, VarZeroVecOwned};

pub type VarZeroVec16<'a, T> = VarZeroVec<'a, T, Index16>;
Copy link
Member

Choose a reason for hiding this comment

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

nit: not sure I like these reexports.

} else {
let bytes = databake::Bake::bake(&self.as_bytes(), env);
// Safe because self.as_bytes is a safe input
quote! { unsafe { zerovec::VarZeroVec::from_bytes_unchecked(#bytes) } }
quote! { unsafe { zerovec::vecs::VarZeroVec16::from_bytes_unchecked(#bytes) } }
Copy link
Member

Choose a reason for hiding this comment

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

nit: we should just use VZV here, the generic gets defaulted

Copy link
Member

Choose a reason for hiding this comment

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

thought: we could implement for all formats and then do a typeid type check to emit the compact thing for VZV16

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't, that's the problem. It gets inferred, so it's very unsafe to not specify it.

Copy link
Member

Choose a reason for hiding this comment

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

@robertbastian hmm, I guess.

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

sold on the safety angle

@robertbastian robertbastian merged commit 257c9bb into unicode-org:main Oct 22, 2024
28 checks passed
@robertbastian robertbastian deleted the zvv branch October 22, 2024 00:33
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

LGTM. I've experienced hard-to-debug safety issues involving VZVs that change between index types. I like the re-exports because it keeps the AST the same size.

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