Skip to content

Conversation

Bryanskiy
Copy link
Contributor

In example:

unsafe extern "C" {
    fn foo();
}

reuse foo as bar;

Desugaring before:

fn bar() {
    foo()
    //~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
}

after:

unsafe extern "C" fn bar() {
    foo()
}

Fixes #127412

r? @petrochenkov

@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. labels Mar 12, 2025
@petrochenkov petrochenkov 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 Mar 12, 2025
@Bryanskiy Bryanskiy force-pushed the delegation-extern-fn branch from f5c21fa to f99d3b9 Compare March 12, 2025 13:14
@Bryanskiy
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 12, 2025
@Bryanskiy Bryanskiy force-pushed the delegation-extern-fn branch from f99d3b9 to 88afeb3 Compare March 12, 2025 13:16
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 12, 2025

📌 Commit 88afeb3 has been approved by petrochenkov

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 Mar 12, 2025
@petrochenkov petrochenkov added the F-fn_delegation `#![feature(fn_delegation)]` label Mar 12, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 13, 2025
…petrochenkov

Delegation: allow foreign fns `reuse`

In example:
```rust
unsafe extern "C" {
    fn foo();
}

reuse foo as bar;
```

Desugaring before:

```rust
fn bar() {
    foo()
    //~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
}
```

after:

```rust
unsafe extern "C" fn bar() {
    foo()
}
```

Fixes rust-lang#127412

r? `@petrochenkov`
@matthiaskrgr
Copy link
Member

@bors r-
#138444 (comment) 🤔

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 13, 2025
@Bryanskiy Bryanskiy force-pushed the delegation-extern-fn branch from 88afeb3 to 63447f2 Compare March 13, 2025 11:13
@Bryanskiy
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 13, 2025
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 13, 2025

📌 Commit 63447f2 has been approved by petrochenkov

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 Mar 13, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 13, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#138126 (Add an opt-out in pretty printing for RTN rendering)
 - rust-lang#138399 (Delegation: allow foreign fns `reuse`)
 - rust-lang#138406 (Update mdbook to 0.4.47)
 - rust-lang#138417 (minor interpreter cleanups)
 - rust-lang#138420 (Adapt to LLVM dropping CfiFunctionIndex::begin()/end())
 - rust-lang#138423 (Don't emit error within cast function, propagate it as a `CastError`)
 - rust-lang#138425 (Remove `feature = "hash_raw_entry"`)
 - rust-lang#138427 (Fix RISC-V VxWorks LLVM target triples)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 41d6e6e into rust-lang:master Mar 13, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 13, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 13, 2025
Rollup merge of rust-lang#138399 - Bryanskiy:delegation-extern-fn, r=petrochenkov

Delegation: allow foreign fns `reuse`

In example:
```rust
unsafe extern "C" {
    fn foo();
}

reuse foo as bar;
```

Desugaring before:

```rust
fn bar() {
    foo()
    //~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
}
```

after:

```rust
unsafe extern "C" fn bar() {
    foo()
}
```

Fixes rust-lang#127412

r? `@petrochenkov`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-fn_delegation `#![feature(fn_delegation)]` 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delegation: It's impossible to reuse foreign fns
5 participants