-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Avoid panic branch in EscapeDefault::backslash
and EscapeDebug::backslash
.
#121805
Conversation
r? |
Are you sure that that's where the panic comes from? As far as I can tell, LLVM is able to optimize this out. |
I assume the |
This is the wrong panic, the See how the BB in bjorn's Godbolt example is only reached from two comparisons that depend on the result of
It will never trigger but cannot be optimized out since rust/library/core/src/char/mod.rs Line 342 in 9db7a74
I'll close this PR, but feel free to |
…t-inline, r=joboet Optimize character escaping. Allow optimization of panicking branch in `EscapeDebug`, see rust-lang#121805. r? `@joboet`
Rollup merge of rust-lang#124307 - reitermarkus:escape-debug-size-hint-inline, r=joboet Optimize character escaping. Allow optimization of panicking branch in `EscapeDebug`, see rust-lang#121805. r? `@joboet`
See japaric/ufmt#52 and https://github.com/andrewgazelka/ufmt/blob/e97ce1a86cfcc9fa36ffab6ee62762c00e4b3fc9/src/impls/core.rs#L62.
This avoids the unreachable panicking branch in
char::escape_debug
.Not sure what the best way to test this is.