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

automata: remove some unsafe code #1189

Closed
wants to merge 1 commit into from

Conversation

joshlf
Copy link

@joshlf joshlf commented May 4, 2024

Note that the changes in wire.rs require zerocopy's "derive" feature, but the changes in accel.rs do not. If you'd prefer not to take a dependency on a proc macro derive, we can still salvage some of this PR.

@BurntSushi
Copy link
Member

I was aware of zerocopy (and similar crates) when I wrote this code, and knew that it could probably eliminate some unsafe blocks. But as a rule of thumb, I don't add dependencies to regex. I have spent a lot of time and effort to keep its dependency tree small and reasonable (the entire tree is owned by me for example). So not only does taking a proc macro dependency not meet my bar, zerocopy itself doesn't either. Or at least, it would need to provide a much bigger benefit.

The way to get rid of these unsafe blocks is to push on the "safe transmute" effort I think.

@joshlf
Copy link
Author

joshlf commented May 4, 2024

Yeah no worries, I understand the desire to avoid dependencies. We do the same. Happy to just close this if you'd prefer.

As for safe transmute, IIUC (@jswrenn is more directly involved and can provide more context), the idea is that safe transmute will basically just enable a trait bound, and you'll still need library code to provide useful abstractions given that bound. Roughly, safe transmute will replace zerocopy-derive, but not zerocopy (and presumably the same for bytemuck/bytemuck-derive, etc), and code like this PR would still require zerocopy in order to avoid writing unsafe.

@BurntSushi
Copy link
Member

Aye. Understood. Thanks for the attempt! I do overall support trying to remove unsafe blocks, but probably not with the addition of other dependencies.

@BurntSushi BurntSushi closed this May 5, 2024
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.

None yet

2 participants