Skip to content

Debug print char 0 as '\0' rather than '\u{0}' - #95345

Merged
bors merged 1 commit into
rust-lang:masterfrom
dtolnay:escape0
Mar 27, 2022
Merged

Debug print char 0 as '\0' rather than '\u{0}'#95345
bors merged 1 commit into
rust-lang:masterfrom
dtolnay:escape0

Conversation

@dtolnay

Copy link
Copy Markdown
Member
println!("{:?}","foo\0");
  • Before:"foo\u{0}"
  • After:"foo\0"
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.

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 26, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @kennytm

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 26, 2022
@Dylan-DPC

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Mar 26, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 72ee247 has been approved by Dylan-DPC

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 26, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 26, 2022
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.
@Dylan-DPCDylan-DPC mentioned this pull request Mar 26, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 26, 2022
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.
@Dylan-DPCDylan-DPC mentioned this pull request Mar 26, 2022
@Dylan-DPC

Copy link
Copy Markdown
Member

failed in rollup

@bors r-

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 27, 2022
@dtolnay

Copy link
Copy Markdown
MemberAuthor

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.

@dtolnaydtolnay added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 27, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 27, 2022
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.
@dtolnay

Copy link
Copy Markdown
MemberAuthor

@bors

bors commented Mar 27, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 2ac9efb has been approved by Dylan-DPC

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Mar 27, 2022
@bors

bors commented Mar 27, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 2ac9efb with merge b03c0e5730b82e0d5e171695973b527dc5a8beca...

@bors

bors commented Mar 27, 2022

Copy link
Copy Markdown
Collaborator

💔 Test failed - checks-actions

@borsbors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 27, 2022
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web)(plain)

Click to see the possible cause of the failure (guessed by this bot)
To only update this specific test, also pass `--test-args concurrency/libc_pthread_cond.rs`
error: 1 errors occurred comparing output.
status: exit status: 101
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin/miri" "tests/run-pass/concurrency/libc_pthread_cond.rs" "-L" "/tmp/compiletestjW70wG" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletestjW70wG/concurrency/libc_pthread_cond.stage-id" "-A" "unused" "--edition" "2018" "-Astable-features" "--sysroot" "/home/user/.cache/miri/HOST" "-Zmiri-disable-isolation" "-Zmiri-check-number-validity" "-L" "/tmp/compiletestjW70wG/concurrency/libc_pthread_cond.stage-id.aux"
------------------------------------------
------------------------------------------
stderr:
---
To only update this specific test, also pass `--test-args concurrency/sync.rs`
error: 2 errors occurred comparing output.
status: exit status: 101
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin/miri" "tests/run-pass/concurrency/sync.rs" "-L" "/tmp/compiletestjW70wG" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletestjW70wG/concurrency/sync.stage-id" "-A" "unused" "--edition" "2018" "-Astable-features" "--sysroot" "/home/user/.cache/miri/HOST" "-Zmiri-disable-isolation" "-Zmiri-check-number-validity" "-L" "/tmp/compiletestjW70wG/concurrency/sync.stage-id.aux"
------------------------------------------
------------------------------------------
stderr:
---
To only update this specific test, also pass `--test-args vec.rs`
error: 1 errors occurred comparing output.
status: exit status: 101
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin/miri" "tests/run-pass/vec.rs" "-L" "/tmp/compiletestjW70wG" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletestjW70wG/vec.stage-id" "-A" "unused" "--edition" "2018" "-Astable-features" "--sysroot" "/home/user/.cache/miri/HOST" "-Zmiri-tag-raw-pointers" "-Zmiri-check-number-validity" "-L" "/tmp/compiletestjW70wG/vec.stage-id.aux"
------------------------------------------
------------------------------------------
stderr:
---
.......... (60/61)
(61/61)
/checkout/src/test/rustdoc-gui/escape-key.goml escape-key... FAILED
[ERROR] (line 6) TimeoutError: waiting for selector "#search h1" failed: timeout 30000ms exceeded: for command `wait-for: "#search h1" // The search element is empty before the first search `
Build completed unsuccessfully in 0:00:43

@dtolnay

Copy link
Copy Markdown
MemberAuthor

@bors retry

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 27, 2022
@bors

bors commented Mar 27, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 2ac9efb with merge d7aca22...

@bors

bors commented Mar 27, 2022

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: Dylan-DPC
Pushing d7aca22 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Mar 27, 2022
@bors
bors merged commit d7aca22 into rust-lang:masterMar 27, 2022
@rustbotrustbot added this to the 1.61.0 milestone Mar 27, 2022
@dtolnay
dtolnay deleted the escape0 branch March 27, 2022 19:05
@rust-timer

Copy link
Copy Markdown
Collaborator

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

krtab added a commit to krtab/xmlparser that referenced this pull request Oct 12, 2022
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.
krtab added a commit to krtab/xmlparser that referenced this pull request Oct 12, 2022
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
krtab added a commit to krtab/xmlparser that referenced this pull request Oct 12, 2022
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
wincent added a commit to wincent/docvim that referenced this pull request Sep 8, 2023
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
@dtolnaydtolnay added T-libs Relevant to the library team, which will review and decide on the PR/issue. A-fmt Area: `core::fmt` and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 14, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-fmtArea: `core::fmt`merged-by-borsThis PR was explicitly merged by bors.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@dtolnay@rust-highfive@Dylan-DPC@bors@rust-log-analyzer@rust-timer@kennytm@rustbot