Visitar URL original
Use EII for #[panic_handler] by bjorn3 · Pull Request #159016 · rust-lang/rust · GitHub
Skip to content

Use EII for #[panic_handler] - #159016

Draft
bjorn3 wants to merge 7 commits into
rust-lang:mainfrom
bjorn3:eii_panic_handler
Draft

bjorn3 wants to merge 7 commits into
rust-lang:mainfrom
bjorn3:eii_panic_handler

Conversation

@bjorn3

@bjorn3 bjorn3 commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

While we can't yet use EIIs for things like the global allocator due to missing platform support, we can safely use it for #[panic_handler] as that doesn't require any object file format features. Just matching symbol names.

This gets rid of one of the two remaining weak lang items.

TODO

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-minicore` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 9, 2026
@bjorn3

bjorn3 commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

cc @jdonszelmann

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@bjorn3
bjorn3 force-pushed the eii_panic_handler branch from ecd1f4c to 2f001d2 Compare July 24, 2026 09:48

/// Attribute macro applied to a function to register it as a panic handler.
///
/// See also [`core::panic::PanicInfo`](crate::panic::PanicInfo).

@bjorn3 bjorn3 Jul 24, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There are probably better pages to link to.

View changes since the review

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@bjorn3
bjorn3 force-pushed the eii_panic_handler branch from 6f7844f to 43f6678 Compare August 4, 2026 13:31
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@bjorn3
bjorn3 force-pushed the eii_panic_handler branch from 43f6678 to efeefa8 Compare November 6, 2026 16:07
@rustbot rustbot added the A-panic Area: Panicking machinery label Nov 6, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@bjorn3
bjorn3 force-pushed the eii_panic_handler branch from efeefa8 to bd62b77 Compare November 9, 2026 12:35
@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Nov 9, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

The symbol name of the EII impl will now get changed to match the EII
decl whenever there is no default impl. This already works across all
backends and targets unlike the weak symbol aliases that we currently
use. When there is a default impl, we will still use weak symbol
aliases.
The only way it was possible to skip needing to declare #[panic_handler]
is using #![no_core], which is unstable anyway. Always requiring
\#[panic_handler] makes things more consistent and avoids having to
special case several MIR optimizations for the absence of #[panic_handler].
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  --> library/core/src/panicking.rs:17:1
   |
17 | #[eii(panic_handler)]
   | ^^^^^^^^^^^^^^^^^^^^^
18 | fn panic_impl(pi: &core::panic::PanicInfo<'_>) -> !;
   |    ---------- `#[eii]` is used on this item, which is part of another item's local scope

error: free function without a body
  --> library/core/src/panicking.rs:18:1
   |
18 | fn panic_impl(pi: &core::panic::PanicInfo<'_>) -> !;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
   |                                                    |
   |                                                    help: provide a definition for the function: `{ <body> }`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0658`.
Couldn't compile the test.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-panic Area: Panicking machinery A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-minicore` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants