Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
65c1722
add CSE optimization tests for iterating over slice
is57primenumber Dec 16, 2025
eb101b1
Fix(lib/win/thread): Ensure `Sleep`'s usage passes over the requested…
PaulDance Dec 18, 2025
bc0cce1
ptr_aligment_type: add more APIs
GrigorenkoPV Nov 9, 2025
76438f0
Add codegen test for issue 138497
jamie-osec Aug 14, 2025
fdc7cfd
x86 soft-float feature: mark it as forbidden rather than unstable
RalfJung Jan 18, 2026
bed40af
std: avoid tearing `dbg!` prints
joboet Dec 10, 2025
f80c137
update `dbg!` clippy lint
joboet Dec 12, 2025
ee24f22
update UI tests
joboet Dec 13, 2025
764ac2b
relnotes: fix 1.93's `as_mut_array` methods
cuviper Jan 23, 2026
4b25ccd
Rename `DepKindStruct` to `DepKindVTable`
Zalathar Jan 24, 2026
23e5b69
Use rustc_proc_macro in rust-analyzer-proc-macro-srv
bjorn3 Jan 22, 2026
eec5320
Disable proc-macro-srv tests on stage 0
bjorn3 Jan 24, 2026
ef819e4
Remove a couple of unnecessary impls
bjorn3 Oct 3, 2025
dabae7e
Handle FreeFunctions outside with_api_handle_types
bjorn3 Oct 3, 2025
4dc28c5
Expand with_api_handle_types
bjorn3 Oct 3, 2025
2f44019
Move all bridge methods into a single type
bjorn3 Jan 22, 2026
9481890
Various simplifications after moving all bridge methods to a single type
bjorn3 Jan 22, 2026
8a119c3
Merge FreeFunctions trait into Server trait
bjorn3 Jan 22, 2026
d9ec1ae
Get rid of MarkedTypes
bjorn3 Oct 3, 2025
e8c48c6
Fix review comments
bjorn3 Jan 23, 2026
a06fdc1
Fix 'the the' typo in library/core/src/array/iter.rs
vinDelphini Jan 24, 2026
b651be2
Rollup merge of #145393 - clubby789:issue-138497, r=Mark-Simulacrum
matthiaskrgr Jan 25, 2026
2da5959
Rollup merge of #148764 - GrigorenkoPV:aligment_api, r=scottmcm
matthiaskrgr Jan 25, 2026
cc666ba
Rollup merge of #149869 - joboet:torn-dbg, r=Mark-Simulacrum
matthiaskrgr Jan 25, 2026
9dffb21
Rollup merge of #150065 - is57primenumber:add-slice-cse-test, r=Mark-…
matthiaskrgr Jan 25, 2026
3850473
Rollup merge of #150842 - PaulDance:patches/fix-win7-sleep, r=Mark-Si…
matthiaskrgr Jan 25, 2026
996992e
Rollup merge of #151505 - bjorn3:proc_macro_refactors, r=petrochenkov…
matthiaskrgr Jan 25, 2026
93d5b4f
Rollup merge of #151560 - cuviper:relnotes-as_mut_array, r=Mark-Simul…
matthiaskrgr Jan 25, 2026
17ba7f2
Rollup merge of #151317 - RalfJung:x86-soft-float, r=workingjubilee
matthiaskrgr Jan 25, 2026
119eea2
Rollup merge of #151577 - Zalathar:dep-kind-vtable, r=Kivooeo
matthiaskrgr Jan 25, 2026
d83f2eb
Rollup merge of #151620 - vinDelphini:fix-typo-library-core, r=joboet
matthiaskrgr Jan 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
std: avoid tearing dbg! prints
  • Loading branch information
joboet committed Jan 21, 2026
commit bed40af305e84b422c68caa2b5828547ce459e4a
4 changes: 3 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,9 @@ extern crate std as realstd;

// The standard macros that are not built-in to the compiler.
#[macro_use]
mod macros;
#[doc(hidden)]
#[unstable(feature = "std_internals", issue = "none")]
pub mod macros;

// The runtime entry point and a few unstable public functions used by the
// compiler
Expand Down
77 changes: 56 additions & 21 deletions library/std/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,35 +347,70 @@ macro_rules! eprintln {
/// [`debug!`]: https://docs.rs/log/*/log/macro.debug.html
/// [`log`]: https://crates.io/crates/log
#[macro_export]
#[allow_internal_unstable(std_internals)]
#[cfg_attr(not(test), rustc_diagnostic_item = "dbg_macro")]
#[stable(feature = "dbg_macro", since = "1.32.0")]
macro_rules! dbg {
// NOTE: We cannot use `concat!` to make a static string as a format argument
// of `eprintln!` because `file!` could contain a `{` or
// `$val` expression could be a block (`{ .. }`), in which case the `eprintln!`
// will be malformed.
() => {
$crate::eprintln!("[{}:{}:{}]", $crate::file!(), $crate::line!(), $crate::column!())
};
($val:expr $(,)?) => {
($($val:expr),+ $(,)?) => {
$crate::macros::dbg_internal!(() () ($($val),+))
};
}

/// Internal macro that processes a list of expressions and produces a chain of
/// nested `match`es, one for each expression, before finally calling `eprint!`
/// with the collected information and returning all the evaluated expressions
/// in a tuple.
///
/// E.g. `dbg_internal!(() () (1, 2))` expands into
/// ```rust, ignore
/// match 1 {
/// tmp_1 => match 2 {
/// tmp_2 => {
/// eprint!("...", &tmp_1, &tmp_2, /* some other arguments */);
/// (tmp_1, tmp_2)
/// }
/// }
/// }
/// ```
///
/// This is necessary so that `dbg!` outputs don't get torn, see #136703.
#[doc(hidden)]
#[rustc_macro_transparency = "semiopaque"]
pub macro dbg_internal {
(($($piece:literal),+) ($($processed:expr => $bound:expr),+) ()) => {{
$crate::eprint!(
$crate::concat!($($piece),+),
$(
$crate::stringify!($processed),
// The `&T: Debug` check happens here (not in the format literal desugaring)
// to avoid format literal related messages and suggestions.
&&$bound as &dyn $crate::fmt::Debug
),+,
// The location returned here is that of the macro invocation, so
// it will be the same for all expressions. Thus, label these
// arguments so that they can be reused in every piece of the
// formatting template.
file=$crate::file!(),
line=$crate::line!(),
column=$crate::column!()
);
// Comma separate the variables only when necessary so that this will
// not yield a tuple for a single expression, but rather just parenthesize
// the expression.
($($bound),+)
}},
(($($piece:literal),*) ($($processed:expr => $bound:expr),*) ($val:expr $(,$rest:expr)*)) => {
// Use of `match` here is intentional because it affects the lifetimes
// of temporaries - https://stackoverflow.com/a/48732525/1063961
match $val {
tmp => {
$crate::eprintln!("[{}:{}:{}] {} = {:#?}",
$crate::file!(),
$crate::line!(),
$crate::column!(),
$crate::stringify!($val),
// The `&T: Debug` check happens here (not in the format literal desugaring)
// to avoid format literal related messages and suggestions.
&&tmp as &dyn $crate::fmt::Debug,
);
tmp
}
tmp => $crate::macros::dbg_internal!(
($($piece,)* "[{file}:{line}:{column}] {} = {:#?}\n")
($($processed => $bound,)* $val => tmp)
($($rest),*)
),
}
};
($($val:expr),+ $(,)?) => {
($($crate::dbg!($val)),+,)
};
},
}