-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Debug print char 0 as '\0' rather than '\u{0}' #95345
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
@bors r+ |
📌 Commit 72ee247 has been approved by |
Debug print char 0 as '\0' rather than '\u{0}' ```rust println!("{:?}", "foo\0"); ``` - **Before:** `"foo\u{0}"` - **After:** `"foo\0"` ```rust println!("{:?}", '\0'); ``` - **Before:** `'\u{0}'` - **After:** `'\0'` `'\0'` will be more recognizable to everyone than `'\u{0}'` because it's how we talk about character 0 in all of our docs and example code, such as https://doc.rust-lang.org/std/ffi/index.html, https://doc.rust-lang.org/std/ffi/struct.CStr.html, https://doc.rust-lang.org/std/ffi/struct.CString.html.
Debug print char 0 as '\0' rather than '\u{0}' ```rust println!("{:?}", "foo\0"); ``` - **Before:** `"foo\u{0}"` - **After:** `"foo\0"` ```rust println!("{:?}", '\0'); ``` - **Before:** `'\u{0}'` - **After:** `'\0'` `'\0'` will be more recognizable to everyone than `'\u{0}'` because it's how we talk about character 0 in all of our docs and example code, such as https://doc.rust-lang.org/std/ffi/index.html, https://doc.rust-lang.org/std/ffi/struct.CStr.html, https://doc.rust-lang.org/std/ffi/struct.CString.html.
That looks like ripgrep's test suite (which cargotest runs). As of BurntSushi/ripgrep#1722 ripgrep's test suite is no longer sensitive to this PR. I put up #95355 to import a newer version of ripgrep's test suite into cargotest. |
Bump the ripgrep commit exercised by cargotest This update goes from BurntSushi/ripgrep@3de31f7 (Aug 1, 2019) to current master, BurntSushi/ripgrep@ced5b92 (March 21, 2022). I need this in order to pick up BurntSushi/ripgrep#1722, which picked up BurntSushi/bstr#58, which unblocks rust-lang#95345. Ripgrep uses the Debug representation of a `BStr` in some of its tests. In old versions of bstr, that used to just use the standard library's `escape_debug()` implementation, so the output ends up being sensitive to whether the standard library renders character 0 as `\u{0}` or as `\0`. The newer bstr always renders character 0 as `\0` and ripgrep's test suite has been correspondingly updated.
@bors r=Dylan-DPC |
📌 Commit 2ac9efb has been approved by |
⌛ Testing commit 2ac9efb with merge b03c0e5730b82e0d5e171695973b527dc5a8beca... |
💔 Test failed - checks-actions |
The job Click to see the possible cause of the failure (guessed by this bot)
|
@bors retry |
☀️ Test successful - checks-actions |
Finished benchmarking commit (d7aca22): comparison url. Summary: This benchmark run did not return any relevant results. 6 results were found to be statistically significant but too small to be relevant. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
This follows this PR in rustc: <rust-lang/rust#95345> Which breakage was discussed here: <rust-lang/rust#95732> Because this landed in 1.61.0, the MSRV has to be updated accordingly.
This follows this PR in rustc: <rust-lang/rust#95345> Which breakage was discussed here: <rust-lang/rust#95732> Still relying on \0 would require bumping the MSRV to 1.61.0
This follows this PR in rustc: <rust-lang/rust#95345> Which breakage was discussed here: <rust-lang/rust#95732> Still relying on \0 would require bumping the MSRV to 1.61.0
To 1.72 rustup update stable rustc --version # rustc 1.72.0 (5680fa18f 2023-08-23) cargo fix --allow-dirty # tells me to set resolver vim Cargo.toml # set the resolver cargo build cargo test # see snapshot failure UPDATE_SNAPSHOTS=1 cargo test # update snapshot cargo test # confirm snapshot failure is gone Context for the resolver warning: warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"` note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest Context for the snapshot failure: ... I sure wish I could find the changelog entry or an issue or a commit explaining why `std::fmt` (via `format!("{:#?}", ...)`) started outputting "\0" as "\0" instead of "\u{0}", but I can't find it... - https://releases.rs/ - https://doc.rust-lang.org/std/fmt/ - https://github.com/search?q=repo%3Arust-lang%2Frust+str%3A%3Afmt&type=issues ... no wait for it, wait for it! Here it is: - rust-lang/rust@2ac9efb - https://github.com/rust-lang/rust/releases/tag/1.61.0 (first appeared in this version, but not mentioned in changelog) - rust-lang/rust#95345
"foo\u{0}"
"foo\0"
'\u{0}'
'\0'
'\0'
will be more recognizable to everyone than'\u{0}'
because it's how we talk about character 0 in all of our docs and example code, such as https://doc.rust-lang.org/std/ffi/index.html, https://doc.rust-lang.org/std/ffi/struct.CStr.html, https://doc.rust-lang.org/std/ffi/struct.CString.html.