Skip to content
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

Merged
merged 1 commit into from
Mar 27, 2022
Merged

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Mar 26, 2022

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.

@rustbot rustbot 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
Collaborator

r? @kennytm

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

@rust-highfive rust-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
Member

@bors r+

@bors
Copy link
Contributor

bors commented Mar 26, 2022

📌 Commit 72ee247 has been approved by Dylan-DPC

@bors bors 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-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-DPC
Copy link
Member

failed in rollup

@bors r-

@bors bors 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
Member Author

dtolnay commented Mar 27, 2022

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.

@dtolnay dtolnay added S-blocked Status: Marked as 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
Member Author

dtolnay commented Mar 27, 2022

@bors r=Dylan-DPC

@bors
Copy link
Contributor

bors commented Mar 27, 2022

📌 Commit 2ac9efb has been approved by Dylan-DPC

@bors bors 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: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Mar 27, 2022
@bors
Copy link
Contributor

bors commented Mar 27, 2022

⌛ Testing commit 2ac9efb with merge b03c0e5730b82e0d5e171695973b527dc5a8beca...

@bors
Copy link
Contributor

bors commented Mar 27, 2022

💔 Test failed - checks-actions

@bors bors 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
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
Member Author

dtolnay commented Mar 27, 2022

@bors retry

@bors bors 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
Copy link
Contributor

bors commented Mar 27, 2022

⌛ Testing commit 2ac9efb with merge d7aca22...

@bors
Copy link
Contributor

bors commented Mar 27, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 27, 2022
@bors bors merged commit d7aca22 into rust-lang:master Mar 27, 2022
@rustbot rustbot 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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants