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

Support call and drop terminators in custom mir #105814

Merged
merged 1 commit into from
Dec 18, 2022

Conversation

JakobDegen
Copy link
Contributor

The only caveat with this change is that cleanup blocks are not supported. I would like to add them, but it's not quite clear to me what the best way to do that is, so I'll have to think about it some more.

r? @oli-obk

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 17, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 17, 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

//! let popped;
//!
//! {
//! Call(unused, pop, Vec::push(v, value))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be neat if we actually supported

//!             unused = Vec::push(v, value) -> pop

Copy link
Contributor Author

@JakobDegen JakobDegen Dec 17, 2022

Choose a reason for hiding this comment

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

Yeah, I thought about this. There's a couple reasons I'm hesitant to do it:

  • We'd need to use => instead of ->, because of follow set rules. That's fine, although it's not the most intuitive syntax
  • More macros means worse error messages
  • Supporting cleanup blocks. Presumably we will eventually want to support those, and I'm not sure what that would look like in connection with this, especially once Refactor unwind in MIR #102906 lands. Possibly -> pop, Unreachable(), -> pop, Abort(), or -> pop, other_block are fine though?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yea, I don't think that syntax should happen in this PR and at best any such syntax should desugar to what you have now.


// EMIT_MIR terminators.drop_second.built.after.mir
#[custom_mir(dialect = "built")]
fn drop_second<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can write mem::forget without an intrinsic now 😄

@oli-obk
Copy link
Contributor

oli-obk commented Dec 17, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 17, 2022

📌 Commit 3d849ae has been approved by oli-obk

It is now in the queue for this repository.

@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 Dec 17, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 17, 2022
…-obk

Support call and drop terminators in custom mir

The only caveat with this change is that cleanup blocks are not supported. I would like to add them, but it's not quite clear to me what the best way to do that is, so I'll have to think about it some more.

r? `@oli-obk`
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 17, 2022
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#104854 (Symlink `build/host` -> `build/$HOST_TRIPLE`)
 - rust-lang#105458 (Allow blocking `Command::output`)
 - rust-lang#105559 (bootstrap: Allow installing `llvm-tools`)
 - rust-lang#105789 (rustdoc: clean up margin CSS for scraped examples)
 - rust-lang#105792 (docs: add long error explanation for error E0320)
 - rust-lang#105814 (Support call and drop terminators in custom mir)
 - rust-lang#105829 (Speed up tidy)
 - rust-lang#105836 (std::fmt: Use args directly in example code)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit eaf2f26 into rust-lang:master Dec 18, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 18, 2022
@JakobDegen JakobDegen deleted the custom-mir-terms branch January 1, 2023 21:27
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant 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.

4 participants