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

Switch from annotation approach to new ABI string approach #2761

Merged

Conversation

acfoltzer
Copy link

cc @BatmanAoD

Per discussion in #2753, this switches the RFC to describe an ABI string-based approach, rather than an attribute-based approach.

@joshtriplett
Copy link
Member

This looks great to me.

Minor nit: there was a request to use something other than + here, to avoid confusion with C++, and I see no harm in accommodating that. Could you switch it to "C panic" instead?

@joshtriplett
Copy link
Member

Thanks!

Once this is merged, I'd be happy to write some of the current TODO sections.

Copy link
Member

@BatmanAoD BatmanAoD left a comment

Choose a reason for hiding this comment

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

This is great; thank you. I think am going to wait until the current discussion about future-compatibility has reached a bit of a resolution, though, before merging.


Calls to function pointers with non-Rust ABIs, as opposed to declared or defined functions,
currently are permitted to unwind. This RFC does not change this behavior.
When used on declarations of imported functions (e.g., `extern "C+panic" { fn ... }`), or function
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
When used on declarations of imported functions (e.g., `extern "C+panic" { fn ... }`), or function
When used on declarations of imported functions (e.g., `extern "C panic" { fn ... }`) or function

Calls to function pointers with non-Rust ABIs, as opposed to declared or defined functions,
currently are permitted to unwind. This RFC does not change this behavior.
When used on declarations of imported functions (e.g., `extern "C+panic" { fn ... }`), or function
pointers (e.g., `extern "C+panic" fn()`) the `"C+panic"` ABI string means that if the function
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pointers (e.g., `extern "C+panic" fn()`) the `"C+panic"` ABI string means that if the function
pointers (e.g., `extern "C panic" fn()`), the `"C panic"` ABI string means that if the function

the `#[unwind(allowed)]` attribute on a function with a non-"Rust" ABI, Rust
will instead allow an unwind (such as a panic) to proceed through that function
Rust function with a non-"Rust" ABI ("`extern "ABI" fn`") specification. Under this RFC,
functions with the `"C+panic"` ABI string
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
functions with the `"C+panic"` ABI string
functions with the `"C panic"` ABI string

@@ -77,11 +79,16 @@ unwinds. Propagating a Rust panic through non-Rust code is unspecified;
implementations that define the behavior may require target-specific options
for the non-Rust code, or this feature may not be supported at all.

For the purposes of the type system, `"C+panic"` is considered a totally distinct ABI string from
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
For the purposes of the type system, `"C+panic"` is considered a totally distinct ABI string from
For the purposes of the type system, `"C panic"` is considered a totally distinct ABI string from

- Start Date: 2019-08-29
- RFC PR: [rust-lang/rfcs#0000](https:/rust-lang/rfcs/pull/0000)
- Rust Issue: [rust-lang/rust#0000](https:/rust-lang/rust/issues/0000)

# Summary
[summary]: #summary

Provides an annotation to permit functions with explicit ABI specifications
(such as `extern "C"`) to unwind, and affirms that calls to function pointers with explicit ABI specifications may unwind.
Provides a new ABI string `extern "C+panic"` to denote functions that use the C ABI, but may also
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Provides a new ABI string `extern "C+panic"` to denote functions that use the C ABI, but may also
Provides a new ABI string `extern "C panic"` to denote functions that use the C ABI, but may also

@@ -50,21 +50,23 @@ compatible with the unspecified Rust unwinding mechanism.
# Guide-level explanation
[guide-level-explanation]: #guide-level-explanation

When used on Rust functions with non-Rust ABIs (e.g. `extern "C" fn`), the `#[unwind(allowed)]` attribute permits unwinding out of the annotated function; without the attribute, the process will automatically be terminated at the function boundary.
Rust function definitions with the `"C+panic"` ABI string (e.g., `extern "C+panic" fn`) are
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Rust function definitions with the `"C+panic"` ABI string (e.g., `extern "C+panic" fn`) are
Rust function definitions with the `"C panic"` ABI string (e.g., `extern "C panic" fn`) are

@@ -77,11 +79,16 @@ unwinds. Propagating a Rust panic through non-Rust code is unspecified;
implementations that define the behavior may require target-specific options
for the non-Rust code, or this feature may not be supported at all.

For the purposes of the type system, `"C+panic"` is considered a totally distinct ABI string from
`"C"`. While there may be some circumstances where it is sensible to use an `extern "C" fn` in place
of an `extern "C+panic" fn`, and vice-versa, this introduces questions of subtyping and variance
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
of an `extern "C+panic" fn`, and vice-versa, this introduces questions of subtyping and variance
of an `extern "C panic" fn` (or vice-versa) would be useful, this introduces questions of subtyping and variance

text/0000-simple_unwind_annotation.md Outdated Show resolved Hide resolved
the `#[unwind(allowed)]` attribute on a function with a non-"Rust" ABI, Rust
will instead allow an unwind (such as a panic) to proceed through that function
Rust function with a non-"Rust" ABI ("`extern "ABI" fn`") specification. Under this RFC,
functions with the `"C panic"` ABI string
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
functions with the `"C panic"` ABI string
a function with the `"C panic"` ABI string would

Copy link
Author

Choose a reason for hiding this comment

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

I goofed up the grammar elsewhere in this sentence; I'll fix

@BatmanAoD
Copy link
Member

Wow, the GitHub "suggest changes" mechanism is somewhat less useful for PRs-against-PR-branches.

@acfoltzer
Copy link
Author

It's a bit of a mess, particularly when working this concurrently 😂

@BatmanAoD BatmanAoD merged commit 62e9a61 into rust-lang:SimpleUnwindAnnotation Sep 10, 2019
@acfoltzer acfoltzer deleted the SimpleUnwindAnnotation branch September 10, 2019 22:21
@acfoltzer acfoltzer restored the SimpleUnwindAnnotation branch September 10, 2019 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants