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

New macro: pdbg! (pretty debug) #103334

Closed
wants to merge 2 commits into from
Closed

Conversation

amab8901
Copy link
Contributor

@amab8901 amab8901 commented Oct 21, 2022

ACP: rust-lang/libs-team#125

The main intended use-case of this new macro is to relieve the user from having to choose between writing long boilerplate (println!) and having a messy output (dbg!).

This new macro may be helpful especially when exploring new Rust features (for example in Rust playground) for educational purposes to understand how the feature works. It's modeled after the existing dbg! macro, except that it skips the (in some situations) redundant and distracting info about file name and line number. Another difference is that the new pdbg!macro will insert a new line at the end to make it easier for the user to identify where each output begins and ends at a quick glance, which may be helpful for example when outputting an enum or a struct, or some other multi-line output.

The main intended use-case of this new macro is to relieve the user from having to choose between writing long boilerplate (`println!`) and having a messy output (`dbg!`). 

This new macro may be helpful especially when exploring new Rust features (for example in Rust playground) for educational purposes to understand how the feature works. It's modeled after the existing `dbg!` macro, except that it skips the (in some situations) redundant and distracting info about file name and line number. Another difference is that the new `pdbg!`macro will insert a new line at the end to make it easier for the user to identify where each output begins and ends at a quick glance, which may be helpful for example when outputting an enum or a struct, or some other multi-line output.
@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Oct 21, 2022
@rustbot
Copy link
Collaborator

rustbot commented Oct 21, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 21, 2022
@thomcc
Copy link
Member

thomcc commented Oct 21, 2022

I personally would be inclined to say that this probably is better off as something you use in your own projects -- I'm not sure I'm convinced avoiding the file/line part of dbg is worth inclusion in the stdlib given that we already have dbg and println.

That said, if you want to make a case for it: this needs an API change proposal, as mentioned by the bot. See https://std-dev-guide.rust-lang.org/feature-lifecycle/api-change-proposals.html and https://github.com/rust-lang/libs-team/issues/new?assignees=&labels=api-change-proposal%2C+T-libs-api&template=api-change-proposal.md&title=%28My+API+Change+Proposal%29 for how to do that.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking object v0.26.2
    Checking hashbrown v0.12.3
    Checking miniz_oxide v0.4.0
    Checking addr2line v0.16.0
error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
    |
    |
365 | #[feature(pdbg)]
    |
    |
    = note: `-D unused-attributes` implied by `-D warnings`

error: duplicate diagnostic item found: `dbg_macro`.
    |
366 | macro_rules! pdbg {
    | ^^^^^^^^^^^^^^^^^
    |

@scottmcm scottmcm added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 21, 2022
@scottmcm
Copy link
Member

The author has opened an ACP at rust-lang/libs-team#125

@Dylan-DPC
Copy link
Member

The author has closed the ACP and there's no follow-up ACP so I am assuming there's no interest of taking this further. Even if there is, this will get stuck waiting for that ACP to be written and then accepted, so probably better to make the PR after that step.

@Dylan-DPC Dylan-DPC closed this Jul 28, 2023
@Dylan-DPC Dylan-DPC added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. labels Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants