Skip to content

Introduce sys_common::rt::rtprintpanic! to replace sys_common::util functionality - #84697

Merged
bors merged 5 commits into
rust-lang:masterfrom
CDirkx:util
May 20, 2021
Merged

Introduce sys_common::rt::rtprintpanic! to replace sys_common::util functionality#84697
bors merged 5 commits into
rust-lang:masterfrom
CDirkx:util

Conversation

@CDirkx

@CDirkxCDirkx commented Apr 29, 2021

Copy link
Copy Markdown
Contributor

This PR introduces a new macro rtprintpanic!, similar to sys_common::util::dumb_print and uses that macro to replace all sys_common::util functionality.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @m-ou-se

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 29, 2021
Comment threadlibrary/std/src/sys_common/rt.rs Outdated

@CDirkxCDirkxApr 29, 2021

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

The name could be something different, rtwrite, rtprint, rtoutput etc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe something with print in the name would be better. err might suggest it returns from the function or panics or aborts.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

rtprintpanic!? I think I'll also add a comment about that this writes to the designated "panic output", which is just stderr on most platforms.

Comment threadlibrary/std/src/panicking.rs Outdated

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Is there a particular reason why here in panickingintrinsics::abort is used instead of sys::abort_internal? Otherwise this could also be written with rtabort!.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sys::abort_internal calls libc::abort() (at least on unix). intrinsics::abort does not rely on libc or the platform, but simply results in executing an invalid instruction. I don't know if there's a reason to avoid libc::abort() here. It'd require some digging through the git history to see if this was changed on purpose, or added before the alternative existed, or something like that. :(

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll look into it

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I looked through the history, these intrinsics::abort were indeed added before sys::abort_internal existed. As far as I can tell these could be replaced, along with a safety comment added to abort_internal that it's implementation is not allowed to panic (else panicking is stuck in a loop). However there are more occurrences of intrinsics::abort in std that in my opinion could also be replaced, so I think I'm leaving it like this for now and will address those together in a future PR.

@CDirkxCDirkx changed the title Introduce sys_common::rt::rterr to replace sys_common::util functionalityIntroduce sys_common::rt::rterr! to replace sys_common::util functionalityApr 29, 2021
@m-ou-sem-ou-se added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 5, 2021
@CDirkx

Copy link
Copy Markdown
ContributorAuthor

Ready for another look, only changed the name from rterr to rtprintpanic.

@CDirkxCDirkx changed the title Introduce sys_common::rt::rterr! to replace sys_common::util functionalityIntroduce sys_common::rt::rtprintpanic! to replace sys_common::util functionalityMay 14, 2021
@bors

bors commented May 16, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #81858) made this pull request unmergeable. Please resolve the merge conflicts.

@ijackson

Copy link
Copy Markdown
Contributor

I have some Opinions about intrinsics::abort vs abort_internal. I have a branch which I am going to turn in an MR shortly, now #81858 has landed. That has some information about the properties of abort_internal. Should be later today.

@ijackson

Copy link
Copy Markdown
Contributor

See #85377.

@m-ou-se

Copy link
Copy Markdown
Member

@CDirkx Thanks again! This looks good to me. Can you rebase it to include the new abort message in panicking.rs as well?

@m-ou-sem-ou-se added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2021
@CDirkx

Copy link
Copy Markdown
ContributorAuthor

Rebased 👍🏻

@m-ou-se

Copy link
Copy Markdown
Member

Thanks!

@bors r+

@bors

bors commented May 19, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 4ff5ab5 has been approved by m-ou-se

@borsbors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 19, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 19, 2021
Introduce `sys_common::rt::rtprintpanic!` to replace `sys_common::util` functionality
This PR introduces a new macro `rtprintpanic!`, similar to `sys_common::util::dumb_print` and uses that macro to replace all `sys_common::util` functionality.
@bors

bors commented May 20, 2021

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 4ff5ab5 with merge 5ab0f37...

@bors

bors commented May 20, 2021

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: m-ou-se
Pushing 5ab0f37 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label May 20, 2021
@bors
bors merged commit 5ab0f37 into rust-lang:masterMay 20, 2021
@rustbotrustbot added this to the 1.54.0 milestone May 20, 2021
@CDirkx
CDirkx deleted the util branch May 20, 2021 10:47
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libsRelevant 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.

6 participants

@CDirkx@rust-highfive@bors@ijackson@m-ou-se@rustbot