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

Add key and value methods to DebugMap #60458

Merged
merged 2 commits into from Jul 9, 2019

Conversation

@KodrAus
Copy link
Contributor

commented May 1, 2019

Implementation PR for an active (not approved) RFC: rust-lang/rfcs#2696.

Add two new methods to std::fmt::DebugMap for writing the key and value part of a map entry separately:

impl<'a, 'b: 'a> DebugMap<'a, 'b> {
    pub fn key(&mut self, key: &dyn Debug) -> &mut Self;
    pub fn value(&mut self, value: &dyn Debug) -> &mut Self;
}

I want to do this so that I can write a serde::Serializer that forwards to our format builders, so that any T: Serialize can also be treated like a T: Debug.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented May 1, 2019

Some changes occurred in HTML/CSS.

cc @GuillaumeGomez

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented May 1, 2019

r? @rkruppe

(rust_highfive has picked a reviewer for you, use r? to override)

Show resolved Hide resolved src/libcore/fmt/builders.rs Outdated
@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented May 1, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:09f8ab90:start=1556751115564047889,finish=1556751202672966138,duration=87108918249
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:03:46] tidy error: /checkout/src/libcore/fmt/builders.rs:789: trailing whitespace
[00:03:48] some tidy checks failed
[00:03:48] 
[00:03:48] 
[00:03:48] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:48] 
[00:03:48] 
[00:03:48] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:48] Build completed unsuccessfully in 0:00:46
[00:03:48] Build completed unsuccessfully in 0:00:46
[00:03:48] Makefile:67: recipe for target 'tidy' failed
[00:03:48] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:073c598b
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Wed May  1 22:57:22 UTC 2019
---
travis_time:end:05f40901:start=1556751443038903152,finish=1556751443043910921,duration=5007769
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:138d088d
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:104c4aa2
travis_time:start:104c4aa2
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0ed46954
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented May 2, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:1428c5e8:start=1556754481005641291,finish=1556754568799967674,duration=87794326383
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[01:03:59]     Checking core v0.0.0 (/checkout/src/libcore)
[01:04:28]     Checking rustc-std-workspace-core v1.0.0 (/checkout/src/tools/rustc-std-workspace-core)
[01:04:29]     Checking compiler_builtins v0.1.10
[01:04:30]  Documenting alloc v0.0.0 (/checkout/src/liballoc)
[01:04:33] error: `[value]` cannot be resolved, ignoring it...
[01:04:33]    --> /checkout/src/libcore/fmt/builders.rs:722:37
[01:04:33]     |
[01:04:33] 722 |     /// This method, together with [`value`] are an alternative to [`entry`] that
[01:04:33]     |
[01:04:33] note: lint level defined here
[01:04:33]    --> src/liballoc/lib.rs:64:9
[01:04:33]     |
[01:04:33]     |
[01:04:33] 64  | #![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
[01:04:33]     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:33]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[01:04:33] 
[01:04:33] error: `[entry]` cannot be resolved, ignoring it...
[01:04:33]    --> /checkout/src/libcore/fmt/builders.rs:722:69
[01:04:33]     |
[01:04:33] 722 |     /// This method, together with [`value`] are an alternative to [`entry`] that
[01:04:33]     |
[01:04:33]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[01:04:33] 
[01:04:33] 
[01:04:33] error: `[finish]` cannot be resolved, ignoring it...
[01:04:33]    --> /checkout/src/libcore/fmt/builders.rs:727:56
[01:04:33]     |
[01:04:33] 727 |     /// by a corresponding call to `value`. Otherwise [`finish`] will return an error.
[01:04:33]     |
[01:04:33]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[01:04:33] 
[01:04:33] 
[01:04:33] error: `[key]` cannot be resolved, ignoring it...
[01:04:33]    --> /checkout/src/libcore/fmt/builders.rs:781:37
[01:04:33]     |
[01:04:33] 781 |     /// This method, together with [`key`] are an alternative to [`entry`] that
[01:04:33]     |
[01:04:33]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[01:04:33] 
[01:04:33] 
[01:04:33] error: `[entry]` cannot be resolved, ignoring it...
[01:04:33]    --> /checkout/src/libcore/fmt/builders.rs:781:67
[01:04:33]     |
[01:04:33] 781 |     /// This method, together with [`key`] are an alternative to [`entry`] that
[01:04:33]     |
[01:04:33]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[01:04:33] 
[01:04:33] 
[01:04:33] error: `[finish]` cannot be resolved, ignoring it...
[01:04:33]    --> /checkout/src/libcore/fmt/builders.rs:786:56
[01:04:33]     |
[01:04:33] 786 |     /// by a corresponding call to `value`. Otherwise [`finish`] will return an error.
[01:04:33]     |
[01:04:33]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[01:04:33] 
[01:04:33] error: aborting due to 6 previous errors
[01:04:33] error: aborting due to 6 previous errors
[01:04:33] 
[01:04:33] error: Could not document `alloc`.
[01:04:33] 
[01:04:33] Caused by:
[01:04:33]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --edition=2018 --crate-name alloc src/liballoc/lib.rs --color always --target x86_64-unknown-linux-gnu -o /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/doc --markdown-css rust.css --markdown-no-toc --generate-redirect-pages --resource-suffix 1.36.0 --index-page /checkout/src/doc/index.md -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/release/deps --extern compiler_builtins=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-c48a38dddb046cd4.rmeta --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-72f00ef37db6d7ed.rmeta` (exit code: 1)
[01:04:33] 
[01:04:33] 
[01:04:33] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "rustdoc" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-Z" "unstable-options" "-p" "alloc" "--" "--markdown-css" "rust.css" "--markdown-no-toc" "--generate-redirect-pages" "--resource-suffix" "1.36.0" "--index-page" "/checkout/src/doc/index.md"
[01:04:33] 
[01:04:33] 
[01:04:33] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap doc
[01:04:33] Build completed unsuccessfully in 0:07:36
---
travis_time:end:0125f002:start=1556758454464045058,finish=1556758454469730992,duration=5685934
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0710e67a
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:04f9b7a6
travis_time:start:04f9b7a6
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:115858e0
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented May 2, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:06a19a86:start=1556760968689770524,finish=1556761056723445100,duration=88033674576
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
travis_time:start:test_assembly
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:21:15] 
[01:21:15] running 9 tests
[01:21:15] iiiiiiiii
[01:21:15] 
[01:21:15]  finished in 0.157
[01:21:15] travis_fold:end:test_assembly

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:21:31] 
[01:21:31] running 121 tests
[01:21:57] .iiiii...i.....i..i...i..i.i.i..i.ii...i.....i..i....i..........iiii..........i...ii...i.......ii.i. 100/121
[01:22:02] i.i......iii.i.....ii
[01:22:02] 
[01:22:02]  finished in 30.490
[01:22:02] travis_fold:end:test_debuginfo

---
[01:32:22] travis_fold:start:test_stage1-core
travis_time:start:test_stage1-core
Testing core stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:32:22]    Compiling core v0.0.0 (/checkout/src/libcore)
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:229:22
[01:32:27]     |
[01:32:27] 229 |                     .key(&"bar").value(&true)
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:229:34
[01:32:27]     |
[01:32:27] 229 |                     .key(&"bar").value(&true)
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:263:22
[01:32:27]     |
[01:32:27] 263 |                     .key(&"bar").value(&true)
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:263:34
[01:32:27]     |
[01:32:27] 263 |                     .key(&"bar").value(&true)
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:264:22
[01:32:27]     |
[01:32:27] 264 |                     .key(&10).value(&format_args!("{}/{}", 10, 20))
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:264:31
[01:32:27]     |
[01:32:27] 264 |                     .key(&10).value(&format_args!("{}/{}", 10, 20))
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:330:22
[01:32:27]     |
[01:32:27] 330 |                     .key(&"bar")
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:331:22
[01:32:27]     |
[01:32:27] 331 |                     .key(&"invalid")
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:347:22
[01:32:27]     |
[01:32:27] 347 |                     .key(&"bar")
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:363:22
[01:32:27]     |
[01:32:27] 363 |                     .value(&"invalid")
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:27] 
[01:32:27] error[E0658]: use of unstable library feature 'debug_map_key_value': recently added, needs an RFC
[01:32:27]    --> src/libcore/../libcore/tests/fmt/builders.rs:364:22
[01:32:27]     |
[01:32:27] 364 |                     .key(&"bar")
[01:32:27]     |
[01:32:27]     |
[01:32:27]     = help: add #![feature(debug_map_key_value)] to the crate attributes to enable
[01:32:36] error: aborting due to 11 previous errors
[01:32:36] 
[01:32:36] For more information about this error, try `rustc --explain E0658`.
[01:32:36] error: Could not compile `core`.
[01:32:36] error: Could not compile `core`.
[01:32:36] 
[01:32:36] To learn more, run the command again with --verbose.
[01:32:36] 
[01:32:36] 
[01:32:36] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "core" "--" "--quiet"
[01:32:36] 
[01:32:36] 
[01:32:36] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:32:36] Build completed unsuccessfully in 0:23:12
[01:32:36] Build completed unsuccessfully in 0:23:12
[01:32:36] make: *** [check] Error 1
[01:32:36] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:007c3715
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu May  2 03:10:23 UTC 2019

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented May 2, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:19da3155:start=1556774603753861389,finish=1556774688341953287,duration=84588091898
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---

[00:03:29] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:29] tidy error: /checkout/src/libcore/fmt/builders.rs:21: line longer than 100 chars
[00:03:31] some tidy checks failed
[00:03:31] 
[00:03:31] 
[00:03:31] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:31] 
[00:03:31] 
[00:03:31] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:31] Build completed unsuccessfully in 0:00:45
[00:03:31] Build completed unsuccessfully in 0:00:45
[00:03:31] make: *** [tidy] Error 1
[00:03:31] Makefile:67: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:031fa59a
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu May  2 05:28:30 UTC 2019
---
travis_time:end:04c64a27:start=1556774911448222050,finish=1556774911452839210,duration=4617160
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:07818063
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0e7b22cc
travis_time:start:0e7b22cc
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:27ef088b
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

buf: &'a mut (dyn fmt::Write + 'a),
struct PadAdapter<'buf, 'state> {
buf: &'buf mut (dyn fmt::Write + 'buf),
state: &'state mut PadAdapterState,

This comment has been minimized.

Copy link
@KodrAus

KodrAus May 2, 2019

Author Contributor

Shifting the state of the PadAdapter into a dedicated struct here lets value pick up where key left off without having to guess what the state was before.

@KodrAus KodrAus force-pushed the KodrAus:debug_map_entry branch from cdcd0f3 to 1144976 May 2, 2019

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

commented May 2, 2019

@rust-lang/infra: seems like a condition is broken:

Some changes occurred in HTML/CSS.

cc @GuillaumeGomez

@pietroalbini

This comment has been minimized.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

commented May 2, 2019

Ah indeed! My bad.

@KodrAus

This comment has been minimized.

Copy link
Contributor Author

commented May 13, 2019

Very quick, very dirty benchmark:

#![feature(test)]

extern crate test;

use std::{
    cell::Cell,
    fmt::{self, Write},
};

struct NoOpWrite;

impl Write for NoOpWrite {
    fn write_str(&mut self, _: &str) -> fmt::Result {
        Ok(())
    }
}

#[bench]
fn debugmap_entry(b: &mut test::Bencher) {
    struct Map<'a>(Cell<Option<&'a mut test::Bencher>>);

    impl<'a> fmt::Debug for Map<'a> {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            let mut map = f.debug_map();

            let b = self.0.take().unwrap();
            b.iter(|| {
                map.entry(&"a", &42);
            });

            map.finish()
        }
    }

    let _ = write!(NoOpWrite, "{:?}", Map(Cell::new(Some(b))));
}

On my machine, running this on the current nightly and this PR yields:

Before After
36 ns/iter (+/- 7) 44 ns/iter (+/- 2)

So there's a bit of a performance impact like you'd expect, but I don't think it's too significant, and if it is we can inline the implementation in entry.

@KodrAus

This comment has been minimized.

Copy link
Contributor Author

commented May 17, 2019

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented May 19, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:109f09a7:start=1558304054821567414,finish=1558304141345686626,duration=86524119212
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---

[00:03:56] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:56] tidy error: /checkout/src/libcore/fmt/builders.rs:774: line longer than 100 chars
[00:03:56] tidy error: /checkout/src/libcore/fmt/builders.rs:922: trailing whitespace
[00:04:02] some tidy checks failed
[00:04:02] 
[00:04:02] 
[00:04:02] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:02] 
[00:04:02] 
[00:04:02] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:02] Build completed unsuccessfully in 0:01:15
[00:04:02] Build completed unsuccessfully in 0:01:15
[00:04:02] Makefile:67: recipe for target 'tidy' failed
[00:04:02] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:09062f2d
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun May 19 22:19:53 UTC 2019
---
travis_time:end:02464f5f:start=1558304393929465774,finish=1558304393934594586,duration=5128812
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:056b2b6a
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:08d8eec0
travis_time:start:08d8eec0
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:002b604c
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@alexcrichton

This comment has been minimized.

Copy link
Member

commented May 20, 2019

This all looks great to me! I think this is still waiting on the RFC, though, right?

(FWIW I wouldn't personally consider this as requiring an RFC, but I don't mind waiting if one's open!)

@KodrAus

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

Thanks! Yeh, there's an RFC for this at the moment, so I'm also happy to let this sit and wait on that.

@KodrAus KodrAus referenced this pull request Jul 7, 2019

Open

Tracking issue for debug_map_key_value #62482

1 of 3 tasks complete

@KodrAus KodrAus force-pushed the KodrAus:debug_map_entry branch from a4e5831 to e98ea52 Jul 7, 2019

@KodrAus KodrAus added the B-unstable label Jul 7, 2019

@KodrAus

This comment has been minimized.

Copy link
Contributor Author

commented Jul 7, 2019

Alrighty, the RFC has been merged and I've updated the stability attributes to point to the tracking issue.

I think this should be ready to go now!

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Jul 8, 2019

r=me, thanks!

Looks like CI may be failing though?

@KodrAus

This comment has been minimized.

Copy link
Contributor Author

commented Jul 9, 2019

Looks like we're all good!

@bors r=alexcrichton

@Centril Centril closed this Jul 9, 2019

@Centril Centril reopened this Jul 9, 2019

@Centril

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

@bors r=alexcrichton

@bors

This comment has been minimized.

Copy link
Contributor

commented Jul 9, 2019

📌 Commit 70d630f has been approved by alexcrichton

Centril added a commit to Centril/rust that referenced this pull request Jul 9, 2019

Rollup merge of rust-lang#60458 - KodrAus:debug_map_entry, r=alexcric…
…hton

Add key and value methods to DebugMap

Implementation PR for an active (not approved) RFC: rust-lang/rfcs#2696.

Add two new methods to `std::fmt::DebugMap` for writing the key and value part of a map entry separately:

```rust
impl<'a, 'b: 'a> DebugMap<'a, 'b> {
    pub fn key(&mut self, key: &dyn Debug) -> &mut Self;
    pub fn value(&mut self, value: &dyn Debug) -> &mut Self;
}
```

I want to do this so that I can write a `serde::Serializer` that forwards to our format builders, so that any `T: Serialize` can also be treated like a `T: Debug`.

@Centril Centril referenced this pull request Jul 9, 2019

Merged

Rollup of 4 pull requests #62511

bors added a commit that referenced this pull request Jul 9, 2019

Auto merge of #62511 - Centril:rollup-ojzb35x, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #60458 (Add key and value methods to DebugMap)
 - #62090 (typeck: merge opaque type inference logic)
 - #62403 (Replace SliceConcatExt trait with inherent methods and SliceConcat helper trait)
 - #62494 (Remove unused dependencies)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

commented Jul 9, 2019

⌛️ Testing commit 70d630f with merge 909f5a0...

@bors bors merged commit 70d630f into rust-lang:master Jul 9, 2019

3 of 4 checks passed

homu Testing commit 70d630fd5a57d436b6a5064840b69920b10a110c with merge 909f5a049415a815b23502a5498de9a99bbf276b...
Details
pr Build #20190709.4 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details

@KodrAus KodrAus deleted the KodrAus:debug_map_entry branch Jul 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.