Skip to content

Remove unreachable #8

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

hkBst
Copy link
Member

@hkBst hkBst commented May 14, 2025

This improves the API of this crate to not use unreachable any more and is the continuation of rust-lang/rust#138163.

It also eliminates internal unreachable by inlining Mode methods into the *_common functions, and eliminates the resulting duplication by using traits instead. Using traits is much more verbose than a macro-based variant, because they are very explicit, but hopefully also a bit less unclear.

I've tried to use separate commits to explain the story, but have probably only succeeded at the beginning.

There is a companion PR to use this new API here: rust-lang/rust#140999

r? @nnethercote

hkBst added 5 commits May 14, 2025 11:22
The old API exposes `unreachable` in both unescape_unicode and unescape_mixed.
These are conceptually one function, but because their return types are incompatible,
they could not be unified.

The new API takes this insight further to separate unescape_unicode into separate functions,
such that byte functions can return bytes instead of chars.
@rust-cloud-vms rust-cloud-vms bot force-pushed the remove_unreachable branch from f816e0b to 00b6cfd Compare May 14, 2025 11:23
@GuillaumeGomez
Copy link
Member

Gonna take a look later on.

@nnethercote
Copy link

Thanks for splitting this into multiple pieces. I think it's good that @GuillaumeGomez will look at this, it will be good to get another pair of eyes on it after rust-lang/rust#138163.

@GuillaumeGomez
Copy link
Member

Changes look good to me. Now comes the not so fun question: can you add benchmarks please?

@hkBst
Copy link
Member Author

hkBst commented May 21, 2025

Changes look good to me. Now comes the not so fun question: can you add benchmarks please?

Are you thinking about numbers (before the crate split off this was looking like this for the macro variant of this change) or code for this crate? I'm happy to come up with some benchmark code.

@GuillaumeGomez
Copy link
Member

Mostly code, I can check locally when done. Considering it'll impact performance, better check ahead of time. We just need to check the entry functions.

@hkBst
Copy link
Member Author

hkBst commented May 27, 2025

Benchmarks PR: #9

/// Takes the contents of a literal (without quotes)
/// and produces a sequence of errors,
/// which are returned by invoking `error_callback`.
pub fn unescape_for_errors(
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this function? It does the conversion but doesn't actually make use of it. It only provides information if one error occurred. Where is it meant to be used?

@GuillaumeGomez
Copy link
Member

Also need to update the benchmarks.

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