-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Avoid tearing dbg! prints #149859
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
Avoid tearing dbg! prints #149859
Conversation
|
|
|
@joboet The // 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. |
|
That's different, that's warning against combining the output of |
|
If you'd like to see the other approach I've tried you can see it here: abe2246 It should work in theory, it just refuses to compile because of the unstable macro feature despite enabling that feature, in a way I don't understand. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
|
I've found another solution: #149869. |
|
I will close this one in favor of that solution. |
std: avoid tearing `dbg!` prints Fixes rust-lang#136703. This is an alternative to rust-lang#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
std: avoid tearing `dbg!` prints Fixes rust-lang#136703. This is an alternative to rust-lang#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
std: avoid tearing `dbg!` prints Fixes rust-lang#136703. This is an alternative to rust-lang#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
std: avoid tearing `dbg!` prints Fixes rust-lang#136703. This is an alternative to rust-lang#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
std: avoid tearing `dbg!` prints Fixes rust-lang#136703. This is an alternative to rust-lang#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
Rollup merge of #149869 - joboet:torn-dbg, r=Mark-Simulacrum std: avoid tearing `dbg!` prints 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
std: avoid tearing `dbg!` prints Fixes rust-lang/rust#136703. This is an alternative to rust-lang/rust#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
Fixes #136703.
I did attempt a solution which collects all expressions into a tuple
tmpbefore iterating over that tuple using the unstablemacro_metavar_exprtmp.${index()}, but that refused to compile even with#[allow_internal_unstable(macro_metavar_expr)]and/or#![feature(macro_metavar_expr)]:As mentioned in the code comment, the original proposed solution in the issue of simply holding the
stderrlock is undesirable because it can lead to deadlocks.