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

Remove sys::args::Args::inner_debug and use Debug instead #84413

Merged
merged 1 commit into from
Apr 22, 2021

Conversation

CDirkx
Copy link
Contributor

@CDirkx CDirkx commented Apr 21, 2021

This removes the method sys::args::Args::inner_debug on all platforms and implements Debug for Args instead.

I believe this creates a more natural API for the different platforms under sys: export a type Args: Debug + Iterator + ... vs. Args: Iterator + ... and with a method inner_debug.

@rust-highfive
Copy link
Collaborator

r? @m-ou-se

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 21, 2021
@rust-log-analyzer

This comment has been minimized.

@CDirkx CDirkx force-pushed the args_inner_debug branch 2 times, most recently from 17080ca to 6da27a9 Compare April 21, 2021 22:49
@CDirkx
Copy link
Contributor Author

CDirkx commented Apr 21, 2021

The Debug output of std::env::Args and ArgsOs is unchanged by this PR.

@@ -799,7 +799,7 @@ impl DoubleEndedIterator for Args {
#[stable(feature = "std_debug", since = "1.16.0")]
impl fmt::Debug for Args {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Args").field("inner", &self.inner.inner.inner_debug()).finish()
f.debug_struct("Args").field("inner", &format_args!("{:?}", self.inner.inner)).finish()
Copy link
Member

Choose a reason for hiding this comment

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

Why the format_args instead of just passing &self.inner.inner to field()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's better, I forgot field already takes &dyn Debug.

@m-ou-se
Copy link
Member

m-ou-se commented Apr 22, 2021

The Debug output of std::env::Args and ArgsOs is unchanged by this PR.

Even with the # flag? (E.g. the output of dbg!(std::env::args())?)

@CDirkx
Copy link
Contributor Author

CDirkx commented Apr 22, 2021

@m-ou-se
Copy link
Member

m-ou-se commented Apr 22, 2021

Yes, those also produce the same result: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=dbe3d60846cf29e0f4d51f85c6012bfa

They gave different output with the format_args!("{:?}", ..) version you had before. :)

@m-ou-se
Copy link
Member

m-ou-se commented Apr 22, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Apr 22, 2021

📌 Commit 1a6de84 has been approved by m-ou-se

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 22, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#84343 (Remove `ScopeTree::closure_tree`)
 - rust-lang#84376 (Uses flex to fix formatting of h1 at any width)
 - rust-lang#84377 (Followup to rust-lang#83944)
 - rust-lang#84396 (Update LLVM submodule)
 - rust-lang#84402 (Move `sys_common::rwlock::StaticRWLock` etc. to `sys::unix::rwlock`)
 - rust-lang#84404 (Check for intrinsics before coercing to a function pointer)
 - rust-lang#84413 (Remove `sys::args::Args::inner_debug` and use `Debug` instead)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d1f5fc6 into rust-lang:master Apr 22, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 22, 2021
@CDirkx CDirkx deleted the args_inner_debug branch April 22, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants