Skip to content

Have into_ruby return a Cow<[u8]>#833

Merged
reese merged 1 commit intotrunkfrom
reese-into-ruby-u8
Feb 28, 2026
Merged

Have into_ruby return a Cow<[u8]>#833
reese merged 1 commit intotrunkfrom
reese-into-ruby-u8

Conversation

@reese
Copy link
Collaborator

@reese reese commented Feb 27, 2026

Part of #832

Currently, we build everything into str/String types, which assume that the string contents are valid UTF-8. This will not always be the case -- Prism can output strings of any Ruby-supported encoding, so this assumption is unsafe and causes failures. Instead, we should be operating on sequences of u8. This PR is the first step in that direction, making into_ruby return a Cow<'_, [u8]> instead of a Cow<'_, str>, as well as updates emit_op to take &[u8] as a proof-of-concept. Later PRs will move other callers to use u8s, though I didn't want to have a single big-bang PR, so this is cut down to something reasonable for reviewability.

The bulk of this PR is updating callsites, primarily converting str literals from "" to b"" or for locs changing from loc_to_str(loc) to loc.as_slice().

@reese reese marked this pull request as ready for review February 27, 2026 23:34
@reese reese merged commit cbd0d45 into trunk Feb 28, 2026
8 checks passed
@reese reese deleted the reese-into-ruby-u8 branch February 28, 2026 13:03
@reese reese restored the reese-into-ruby-u8 branch February 28, 2026 14:23
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.

2 participants