rust/library/core/src
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 Optimize Layout::array. 2021-11-26 19:30:35 +11:00
array Rollup merge of #90270 - woppopo:const_borrow_trait, r=dtolnay 2021-12-11 17:35:24 +01:00
char Turn all 0x1b_u8 into '\x1b' or b'\x1b' 2021-11-19 18:14:18 +01:00
convert Make From impls of NonZero integer const. 2021-10-20 12:04:58 +09:00
fmt Use non-generic inner function for pointer formatting 2021-11-26 13:59:57 -05:00
future Rollup merge of #91721 - danielhenrymantilla:patch-1, r=joshtriplett 2021-12-11 17:35:27 +01:00
hash Apply suggestions from code review 2021-11-23 23:55:05 +01:00
iter Improve std::iter::zip example. 2021-12-09 17:29:36 -05:00
macros Implement concat_bytes! 2021-12-06 21:05:13 -05:00
mem Apply cfg-bootstrap switch 2021-11-30 10:51:42 -05:00
num Rollup merge of #90897 - jhpratt:fix-incorrect-feature-flags, r=dtolnay 2021-12-10 22:40:29 +01:00
ops Make array::{try_from_fn, try_map} and Iterator::try_find generic over Try 2021-12-02 11:23:50 -08:00
panic Rollup merge of #89897 - jkugelman:must-use-core, r=joshtriplett 2021-10-31 09:20:26 +01:00
prelude Implement concat_bytes! 2021-12-06 21:05:13 -05:00
ptr Intra-doc links apparently don't like pointers? 2021-11-22 02:40:56 -08:00
slice Rollup merge of #91737 - Manishearth:panic-immediate-stdlib, r=joshtriplett 2021-12-11 23:31:50 +01:00
str Delete Utf8Lossy::from_str 2021-12-08 22:54:51 -08:00
stream Auto merge of #91761 - matthiaskrgr:rollup-bjowmvz, r=matthiaskrgr 2021-12-11 03:52:12 +00:00
sync Make From impls of NonZero integer const. 2021-10-20 12:04:58 +09:00
task Rollup merge of #89897 - jkugelman:must-use-core, r=joshtriplett 2021-10-31 09:20:26 +01:00
unicode Regenerate tables for Unicode 14.0.0 2021-10-06 17:49:33 -07:00
any.rs fix doc links for downcast_unchecked 2021-11-20 18:22:05 -05:00
ascii.rs Add #[must_use] to remaining core functions 2021-10-30 18:21:29 -04:00
bool.rs Add primitive documentation to libcore 2021-09-12 02:23:08 +00:00
borrow.rs Make Borrow and BorrowMut impls const 2021-12-04 21:57:39 +09:00
cell.rs Add comments regarding superfluous !Sync impls 2021-11-08 13:07:20 -05:00
clone.rs Update Copy/Clone documentation WRT arrays 2021-11-08 13:11:59 -05:00
cmp.rs Add #[repr(i8)] to Ordering 2021-10-03 20:59:54 -07:00
default.rs Add #[must_use] to remaining core functions 2021-10-30 18:21:29 -04:00
ffi.rs Use target_family = "wasm" 2021-11-10 08:35:42 -08:00
hint.rs Add spin_loop hint for RISC-V architecture 2021-12-05 16:39:21 +08:00
internal_macros.rs Added docs to internal_macro const 2021-10-22 10:07:35 +13:00
intrinsics.rs Rollup merge of #90081 - woppopo:const_write_bytes, r=oli-obk 2021-12-11 23:31:48 +01:00
lazy.rs Make more From impls const 2021-10-18 19:19:28 +09:00
lib.rs Add tracking issue; make empty const too (unstably) 2021-12-06 01:12:59 -08:00
marker.rs Update Copy/Clone documentation WRT arrays 2021-11-08 13:11:59 -05:00
option.rs Rollup merge of #91737 - Manishearth:panic-immediate-stdlib, r=joshtriplett 2021-12-11 23:31:50 +01:00
panic.rs Allow panic!("{}", computed_str) in const fn. 2021-09-15 21:56:43 +01:00
panicking.rs Permit const assertions in stdlib 2021-11-08 17:06:00 -05:00
pin.rs Add #[must_use] to remaining core functions 2021-10-30 18:21:29 -04:00
primitive.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
primitive_docs.rs Update docs. 2021-12-04 19:40:33 +01:00
result.rs Add separate impl of unwrap_failed to avoid constructing trait objects 2021-12-10 13:12:26 +05:30
time.rs Apply cfg-bootstrap switch 2021-11-30 10:51:42 -05:00
tuple.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
unit.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00