Skip to content

Feature gate extern fn methods #1429

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions text/0000-extern-fn-methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
- Feature Name: gate-extern-fn-methods
- Start Date: 2015-12-27
- RFC PR: (leave this empty)
- Rust Issue: #30235

# Summary
[summary]: #summary

Restrict the use of non-Rust ABI methods to a feature gate.

# Motivation
[motivation]: #motivation

Currently we allow this code:

```rust
trait Foo {
extern fn foo(&self);
}
```

In the absense of an ABI string, `extern fn` defaults to using "C". This functionality does not
work well and appears to frequently be a mistake on the part of the user. Since the decision to
support this feature either way should be subject to discussion, this RFC is only proposing the
addition of a feature gate that controls access to this feature.

# Detailed design
[design]: #detailed-design

Detect use of `extern fn` in trait definitions and `impl` blocks that don't have a Rust ABI (either
"Rust" or "rust-call") and disallow it unless a feature gate is enabled.

The name of the feature gate is not important, but `extern-fn-methods` seems like a reasonable name.

# Drawbacks
[drawbacks]: #drawbacks

It may break some existing code, however evidence suggests that code attempting to use this feature
runs into one of the bugs surrounding the feature and therefore already doesn't work.

# Alternatives
[alternatives]: #alternatives

Don't feature gate and instead skip straight to discussion about the feature's support. This isn't
appealing as the feature will continue to be a source of confusion until the discussion is
concluded.

# Unresolved questions
[unresolved]: #unresolved-questions

None