rust/library
Matthias Krüger 90eb610d14
Rollup merge of #91737 - Manishearth:panic-immediate-stdlib, r=joshtriplett
Make certain panicky stdlib functions behave better under panic_immediate_abort

The stdlib has a `panic_immediate_abort` feature that turns panics into immediate aborts, without any formatting/display logic. This feature was [introduced](https://github.com/rust-lang/rust/pull/55011) primarily for codesize-constrained situations.

Unfortunately, this win doesn't quite propagate to `Result::expect()` and `Result::unwrap()`, while the formatting machinery is reduced, `expect()` and `unwrap()` both call `unwrap_failed("msg", &err)` which has a signature of `fn unwrap_failed(msg: &str, error: &dyn fmt::Debug)` and is `#[inline(never)]`. This means that `unwrap_failed` will unconditionally construct a `dyn Debug` trait object even though the object is never used in the function.

Constructing a trait object (even if you never call a method on it!) forces rust to include the vtable and any dependencies. This means that in `panic_immediate_abort` mode, calling expect/unwrap on a Result will pull in a whole bunch of formatting code for the error type even if it's completely unused.

This PR swaps out the function with one that won't require a trait object such that it won't force the inclusion of vtables in the code. It also gates off `#[inline(never)]` in a bunch of other places where allowing the inlining of an abort may be useful (this kind of thing is already done elsewhere in the stdlib).

I don't know how to write a test for this; we don't really seem to have any tests for `panic_immediate_abort` anyway so perhaps it's fine as is.
2021-12-11 23:31:50 +01:00
..
alloc Auto merge of #91761 - matthiaskrgr:rollup-bjowmvz, r=matthiaskrgr 2021-12-11 03:52:12 +00:00
backtrace@b02ed04a7e
core Rollup merge of #91737 - Manishearth:panic-immediate-stdlib, r=joshtriplett 2021-12-11 23:31:50 +01:00
panic_abort
panic_unwind
portable-simd Merge commit 'a8385522ade6f67853edac730b5bf164ddb298fd' into simd-remove-autosplats 2021-12-02 18:27:47 -08:00
proc_macro
profiler_builtins
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Rollup merge of #91782 - maxwase:is_symlink_since_attribute, r=jyn514 2021-12-11 16:02:50 +01:00
stdarch@b70ae88ef2 Update stdarch dependency 2021-12-09 22:33:25 +08:00
test
unwind Android: -ldl must appear after -lgcc when linking 2021-11-30 02:42:35 +00:00