-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Switch from annotation approach to new ABI string approach #2761
Conversation
This looks great to me. Minor nit: there was a request to use something other than |
Thanks! Once this is merged, I'd be happy to write some of the current TODO sections. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functions with the `"C panic"` ABI string | |
a function with the `"C panic"` ABI string would |
There was a problem hiding this comment.
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
Wow, the GitHub "suggest changes" mechanism is somewhat less useful for PRs-against-PR-branches. |
Co-Authored-By: Kyle J Strand <[email protected]>
It's a bit of a mess, particularly when working this concurrently 😂 |
cc @BatmanAoD
Per discussion in #2753, this switches the RFC to describe an ABI string-based approach, rather than an attribute-based approach.