Skip to content

Conversation

@saethlin
Copy link
Member

There are a handful of functions, mostly in core and alloc, which have a mess of attributes on them which try to ensure that they compile down to just intrinsics::abort() when cfg(panic = "immediate-abort"), and otherwise are outlined.

The goal of this change is to officially recognize this pattern: These are entry points to the panic runtime.

The "immediate aborting" of panic = "immediate-abort" is now implemented by replacing calls to entrypoint functions with calls to the intrinsics::abort, instead of manually ensuring that these functions are all #[inline] with bodies that only call intrinsics::abort, or that optimize to such a body.

TODO:

  • Turn the new remap_mir function into a required MirPass.
  • Should #[rustc_panic_entrypoint] imply #[cold] #[inline(never)] #[track_caller]? Is that even easy to implement?

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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 Dec 30, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
For more information about this error, try `rustc --explain E0308`.


This error was generated by the lint-docs tool.
This tool extracts documentation for lints from the source code and places
them in the rustc book. See the declare_lint! documentation
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/macro.declare_lint.html
for an example of the format of documentation this tool expects.

To re-run these tests, run: ./x.py test --keep-stage=0 src/tools/lint-docs
The --keep-stage flag should be used if you have already built the compiler
and are only modifying the doc comments to avoid rebuilding the compiler.

Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools-bin/lint-docs --build-rustc-stage 1 --src /checkout/compiler --out /checkout/obj/build/aarch64-unknown-linux-gnu/md-doc/rustc/src/lints --rustc /checkout/obj/build/aarch64-unknown-linux-gnu/stage1/bin/rustc --rustc-target aarch64-unknown-linux-gnu --validate` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1612:23
Executed at: src/bootstrap/src/core/build_steps/doc.rs:1414:13

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:51:29
  local time: Tue Dec 30 05:01:51 UTC 2025
  network time: Tue, 30 Dec 2025 05:01:51 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

@bors
Copy link
Collaborator

bors commented Dec 30, 2025

☔ The latest upstream changes (presumably #150386) made this pull request unmergeable. Please resolve the merge conflicts.

bx.abort();
bx.unreachable();
return MergingSucc::False;
}
Copy link
Member

Choose a reason for hiding this comment

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

For cg_clif you can add fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); at

and optionally (to skip codegening a bunch of instructions) and
let msg_ptr = crate::constant::pointer_for_anonymous_str(fx, msg_str);

@bjorn3
Copy link
Member

bjorn3 commented Dec 30, 2025

Should #[rustc_panic_entrypoint] imply #[cold] #[inline(never)] #[track_caller]? Is that even easy to implement?

Should be possible to check #[rustc_panic_entrypoint] when computing the CodegenFnAttrs.

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

Labels

O-unix Operating system: Unix-like S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

5 participants