Skip to content

Conversation

@joboet
Copy link
Member

@joboet joboet commented Dec 10, 2025

Fixes #136703.

This is an alternative to #149859. Instead of formatting everything into a string, this PR makes multi-expression dbg! expand into multiple nested matches, with the final match containing a single eprint!. By using macro recursion and relying on hygiene, this allows naming every bound value in that eprint!.

CC @orlp

r? libs

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 10, 2025
@rust-log-analyzer

This comment has been minimized.

@orlp
Copy link
Contributor

orlp commented Dec 11, 2025

Neat solution :) I wasn't sure if we could use helper macros.

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Dec 12, 2025
@joboet joboet marked this pull request as ready for review December 12, 2025 12:25
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 12, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 12, 2025
loop {
let [arm] = arms else { unreachable!("dbg! macro expansion only has single-arm matches") };

match is_async_move_desugar(arm.body).unwrap_or(arm.body).peel_drop_temps().kind {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether this is really necessary, I just copied this from above.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
To only update this specific test, also pass `--test-args delegation/ice-line-bounds-issue-148732.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/delegation/ice-line-bounds-issue-148732.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/delegation/ice-line-bounds-issue-148732" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0106]: missing lifetime specifier
##[error]  --> /checkout/tests/ui/delegation/ice-line-bounds-issue-148732.rs:4:5
   |
---
LL | | }
   | |_^
   |
   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
   = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0277]: `fn() {b}` doesn't implement `Debug`
##[error]  --> /checkout/tests/ui/delegation/ice-line-bounds-issue-148732.rs:4:5
   |
LL | reuse a as b {
   |            - consider calling this function
...
---
---- [ui] tests/ui/mismatched_types/mismatched-types-issue-126222.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/mismatched_types/mismatched-types-issue-126222/mismatched-types-issue-126222.stderr`
diff of stderr:

4 LL |             x => dbg!(x),
5    |                  ^^^^^^^ expected `()`, found integer
6    |
-    = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
8 help: you might have meant to return this value
9    |
10 LL |             x => return dbg!(x),

16 LL |                 dbg!(x)
17    |                 ^^^^^^^ expected `()`, found integer
18    |
-    = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
20 help: you might have meant to return this value
21    |
22 LL |                 return dbg!(x)

28 LL |             _ => dbg!(1)
29    |                  ^^^^^^^ expected `()`, found integer
30    |
-    = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
32 help: you might have meant to return this value
33    |
34 LL |             _ => return dbg!(1)

40 LL |             _ => {dbg!(1)}
41    |                   ^^^^^^^ expected `()`, found integer
42    |
-    = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
44 help: you might have meant to return this value
45    |
46 LL |             _ => {return dbg!(1)}


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args mismatched_types/mismatched-types-issue-126222.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/mismatched_types/mismatched-types-issue-126222.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/mismatched_types/mismatched-types-issue-126222" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/mismatched_types/mismatched-types-issue-126222.rs:7:18
   |
LL |             x => dbg!(x), //~ ERROR mismatched types
   |                  ^^^^^^^ expected `()`, found integer
   |
   = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might have meant to return this value
   |
LL |             x => return dbg!(x), //~ ERROR mismatched types
   |                  ++++++

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/mismatched_types/mismatched-types-issue-126222.rs:15:17
   |
LL |                 dbg!(x) //~ ERROR mismatched types
   |                 ^^^^^^^ expected `()`, found integer
   |
   = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might have meant to return this value
   |
LL |                 return dbg!(x) //~ ERROR mismatched types
   |                 ++++++

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/mismatched_types/mismatched-types-issue-126222.rs:23:18
   |
LL |             _ => dbg!(1) //~ ERROR mismatched types
   |                  ^^^^^^^ expected `()`, found integer
   |
   = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might have meant to return this value
   |
LL |             _ => return dbg!(1) //~ ERROR mismatched types
   |                  ++++++

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/mismatched_types/mismatched-types-issue-126222.rs:30:19
   |
LL |             _ => {dbg!(1)} //~ ERROR mismatched types
   |                   ^^^^^^^ expected `()`, found integer
   |
   = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might have meant to return this value
   |
LL |             _ => {return dbg!(1)} //~ ERROR mismatched types
   |                   ++++++

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0308`.
---
diff of stderr:

5     |     ^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `Dummy`
6     |
7     = note: add `#[derive(Debug)]` to `Dummy` or manually `impl Debug for Dummy`
-     = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+     = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
9 help: consider annotating `Dummy` with `#[derive(Debug)]`
10    --> $DIR/auxiliary/dummy_lib.rs:2:1
11     |


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args modules/issue-107649.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/modules/issue-107649.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/modules/issue-107649" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "ui-testing=no"
stdout: none
--- stderr -------------------------------
error[E0277]: `Dummy` doesn't implement `Debug`
##[error]   --> /checkout/tests/ui/modules/issue-107649.rs:105:5
    |
105 |     dbg!(lib::Dummy); //~ ERROR `Dummy` doesn't implement `Debug`
    |     ^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `Dummy`
    |
    = note: add `#[derive(Debug)]` to `Dummy` or manually `impl Debug for Dummy`
    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `Dummy` with `#[derive(Debug)]`
   --> /checkout/tests/ui/modules/auxiliary/dummy_lib.rs:2:1
    |
  2 + #[derive(Debug)]
  3 | pub struct Dummy;
    |

---
---- [ui] tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics/dbg-macro-move-semantics.stderr`
diff of stderr:

8 LL |     let _ = dbg!(a);
9    |             ^^^^^^^ value used here after move
10    |
-    = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
12 help: consider borrowing instead of transferring ownership
13    |
14 LL |     let _ = dbg!(&a);


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0382]: use of moved value: `a`
##[error]  --> /checkout/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs:9:13
   |
LL |     let a = NoCopy(0);
   |         - move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait
LL |     let _ = dbg!(a);
   |             ------- value moved here
LL |     let _ = dbg!(a); //~ ERROR use of moved value
   |             ^^^^^^^ value used here after move
   |
   = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider borrowing instead of transferring ownership
   |
LL |     let _ = dbg!(&a);
   |                  +

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.
---
diff of stderr:

5    |                       ^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `NotDebug`
6    |
7    = note: add `#[derive(Debug)]` to `NotDebug` or manually `impl Debug for NotDebug`
-    = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
9 help: consider annotating `NotDebug` with `#[derive(Debug)]`
10    |
11 LL + #[derive(Debug)]


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0277]: `NotDebug` doesn't implement `Debug`
##[error]  --> /checkout/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs:9:23
   |
LL |     let _: NotDebug = dbg!(NotDebug); //~ ERROR `NotDebug` doesn't implement `Debug`
   |                       ^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `NotDebug`
   |
   = note: add `#[derive(Debug)]` to `NotDebug` or manually `impl Debug for NotDebug`
   = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `NotDebug` with `#[derive(Debug)]`
   |
LL + #[derive(Debug)]
LL | struct NotDebug;
   |

---
---- [ui] tests/ui/typeck/closure-ty-mismatch-issue-128561.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/typeck/closure-ty-mismatch-issue-128561/closure-ty-mismatch-issue-128561.stderr`
diff of stderr:

15 LL |     b"abc".iter().for_each(|x| dbg!(x));
16    |                                ^^^^^^^ expected `()`, found `&u8`
17    |
-    = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
19 
20 error[E0308]: mismatched types
---
To only update this specific test, also pass `--test-args typeck/closure-ty-mismatch-issue-128561.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/typeck/closure-ty-mismatch-issue-128561.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/typeck/closure-ty-mismatch-issue-128561" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/closure-ty-mismatch-issue-128561.rs:2:32
   |
LL |     b"abc".iter().for_each(|x| x); //~ ERROR: mismatched types
   |                                ^ expected `()`, found `&u8`
   |
help: consider ignoring the value
   |
LL |     b"abc".iter().for_each(|x| _ = x); //~ ERROR: mismatched types
   |                                +++

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/closure-ty-mismatch-issue-128561.rs:4:32
   |
LL |     b"abc".iter().for_each(|x| dbg!(x)); //~ ERROR: mismatched types
   |                                ^^^^^^^ expected `()`, found `&u8`
   |
   = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/closure-ty-mismatch-issue-128561.rs:8:9
   |
LL |         x //~ ERROR: mismatched types
   |         ^ expected `()`, found `&u8`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.
------------------------------------------

---- [ui] tests/ui/typeck/closure-ty-mismatch-issue-128561.rs stdout end ----
---- [ui] tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253/suggest-clone-in-macro-issue-139253.stderr`
diff of stderr:

26 LL |     let c: S = dbg!(field);
27    |                ^^^^^^^^^^^ expected `S`, found `&S`
28    |
-    = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
30 help: consider using clone here
31    |
32 LL |     let c: S = dbg!(field).clone();

38 LL |     let c: S = dbg!(dbg!(field));
39    |                ^^^^^^^^^^^^^^^^^ expected `S`, found `&S`
40    |
-    = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
+    = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
42 help: consider using clone here
43    |
44 LL |     let c: S = dbg!(dbg!(field)).clone();


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args typeck/suggestions/suggest-clone-in-macro-issue-139253.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.rs:13:34
   |
LL |     let a: Struct = dbg!(expand!(field)); //~ ERROR mismatched types [E0308]
   |                                  ^^^^^ expected `S`, found `&S`
   |
help: consider using clone here
   |
LL |     let a: Struct = dbg!(expand!(field: field.clone())); //~ ERROR mismatched types [E0308]
   |                                       +++++++++++++++

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.rs:14:35
   |
LL |     let b: Struct = dbg!(Struct { field }); //~ ERROR mismatched types [E0308]
   |                                   ^^^^^ expected `S`, found `&S`
   |
help: consider using clone here
   |
LL |     let b: Struct = dbg!(Struct { field: field.clone() }); //~ ERROR mismatched types [E0308]
   |                                        +++++++++++++++

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.rs:15:16
   |
LL |     let c: S = dbg!(field); //~ ERROR mismatched types [E0308]
   |                ^^^^^^^^^^^ expected `S`, found `&S`
   |
   = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider using clone here
   |
LL |     let c: S = dbg!(field).clone(); //~ ERROR mismatched types [E0308]
   |                           ++++++++

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.rs:16:16
   |
LL |     let c: S = dbg!(dbg!(field)); //~ ERROR mismatched types [E0308]
   |                ^^^^^^^^^^^^^^^^^ expected `S`, found `&S`
   |
   = note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider using clone here
   |
LL |     let c: S = dbg!(dbg!(field)).clone(); //~ ERROR mismatched types [E0308]
   |                                 ++++++++

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0308`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-libs Relevant 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.

dbg! prints can tear in multi-threading code

5 participants