Rollup of 4 pull requests - #161122
Closed
JonathanBrouwer wants to merge 10 commits into
Closed
Conversation
Take bors try-perf branch into account in verify-channel.sh Forgot about this in rust-lang#160693. r? @Mark-Simulacrum
…, r=tgross35 Stabilize `extern "custom"` tracking issue: rust-lang#140829 reference PR: rust-lang/reference#2300 closes rust-lang#140829 ## Summary An `extern "custom" fn` is a function with a custom ABI that is unknown to rust. Often these are low-level functions that pass arguments in different registers than any standard calling convention. ```rust #[unsafe(naked)] pub unsafe extern "custom" fn __aeabi_uidivmod() { core::arch::naked_asm!( "push {{lr}}", "sub sp, sp, rust-lang#4", "mov r2, sp", "bl {trampoline}", "ldr r1, [sp]", "add sp, sp, rust-lang#4", "pop {{pc}}", trampoline = sym crate::arm::__udivmodsi4 ); } unsafe extern "custom" { fn __fentry__(); } ``` ## Design Because rust doesn't know what calling convention to use, an `extern "custom"` function can only be called via inline assembly or FFI. ``` error: functions with the "custom" ABI cannot be called --> <source>:5:5 | 5 | bar(); | ^^^^^ | note: an `extern "custom"` function can only be called using inline assembly ``` An `extern "custom"` function definition must be a naked function: ``` error: items with the "custom" ABI can only be declared externally or defined via naked functions --> <source>:10:1 | 10 | unsafe extern "custom" fn bar() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: convert this to an `#[unsafe(naked)]` function | 10 + #[unsafe(naked)] 11 | unsafe extern "custom" fn bar() { | ``` An `extern "custom"` function definition must be unsafe. The intent here is that a safety comment is written on how this function may be called. ``` error: functions with the "custom" ABI must be unsafe --> <source>:10:1 | 10 | extern "custom" fn bar() { | ^^^^^^^^^^^^^^^^^^^^^^^^ | help: add the `unsafe` keyword to this definition | 10 | unsafe extern "custom" fn bar() { | ++++++ ``` In an `extern "custom"` block, functions cannot be marked as `safe`: ``` error: foreign functions with the "custom" ABI cannot be safe --> <source>:16:5 | 16 | safe fn foobar(); | ^^^^^^^^^^^^^^^^^ | help: remove the `safe` keyword from this definition | 16 - safe fn foobar(); 16 + fn foobar(); ``` An `extern "custom"` function cannot have any arguments or a return type: ``` error: invalid signature for `extern "custom"` function --> <source>:6:31 | 6 | unsafe extern "custom" fn foo(a: i32) -> i32 { | ^^^^^^ ^^^ | = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | 6 - unsafe extern "custom" fn foo(a: i32) -> i32 { 6 + unsafe extern "custom" fn foo() { | ``` ## Tests - [tests/ui/abi/custom.rs](https://github.com/rust-lang/rust/blob/main/tests/ui/abi/custom.rs) tests that the feature works as expected, e.g. that functions can be defined, symbols are defined, and extern blocks can be used. - [tests/ui/abi/bad-custom.rs](https://github.com/rust-lang/rust/blob/main/tests/ui/abi/bad-custom.rs) checks the restrictions: definitions must be unsafe and naked, attempting to call an `extern "custom"` function gives an error, etc. - ## History * rust-lang#140566 * rust-lang#140829 * rust-lang#140770 * rust-lang#159780 ## unresolved questions None
…crum mailmap: fix nia's gazillion emails Title. The `@hexcat.nl` one isn't used for any existing commits but there's a good chance it will be in the near future.
…, r=Urgau rustdoc: Small `doc_cfg` messages improvements Fixes rust-lang#145075. I was writing a regression test for rust-lang#145075 which was already fixed, saw it was looking like this: <img width="242" height="247" alt="image" src="https://github.com/user-attachments/assets/421e6b4b-698f-4a01-93d9-022eb346d73c" /> So I made some small changes to improve the wording. Now it looks like this: <img width="242" height="247" alt="image" src="https://github.com/user-attachments/assets/c950dd68-a760-4f18-b974-555e05fcfd78" /> r? @Urgau
Contributor
Author
|
@bors r+ p=5 |
Contributor
Contributor
Author
|
@bors p=1 |
Contributor
Author
|
@bors p=5 |
This comment has been minimized.
This comment has been minimized.
Contributor
|
💔 Test for 75ab3e3 failed: CI. Failed job:
|
Contributor
Author
|
@bors retry |
Contributor
|
This pull request was unapproved due to being closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
extern "custom"#158504 (Stabilizeextern "custom")doc_cfgmessages improvements #161105 (rustdoc: Smalldoc_cfgmessages improvements)r? @ghost
Create a similar rollup