about summary refs log tree commit diff
path: root/library/core/src/panic
AgeCommit message (Collapse)AuthorLines
2025-09-21Rollup merge of #145664 - Darksonn:stab-file-with-nul, r=Mark-SimulacrumStuart Cook-1/+2
Stabilize `std::panic::Location::file_as_c_str` Closes: rust-lang/rust#141727 Nominating this for T-lang as per ```@traviscross``` https://github.com/rust-lang/rust/issues/141727#issuecomment-3201318429
2025-09-01Constify conversion traitsltdk-2/+4
2025-08-29Stabilize file_as_c_strAlice Ryhl-1/+2
2025-08-27Rename `Location::file_with_nul` to `file_as_c_str`Alice Ryhl-2/+2
2025-08-02corrected lifetime in core::panic::Location::file return typeIsaac Chen-1/+1
2025-08-02corrected lifetime in core::panic::Location::file return typeIsaac Chen-1/+1
2025-07-29Fix Ord, Eq and Hash implementation of panic::LocationOrson Peters-1/+41
Faster equality compare Add tests Add missing files for tests
2025-06-23Use a NonNull pointerAlice Ryhl-4/+7
2025-06-19Do not include NUL-terminator in computed lengthAlice Ryhl-13/+22
2025-06-11Fix Debug for Location.Mara Bos-1/+12
2025-06-04Add Location::file_with_nulTaylor Cramer-16/+25
This is useful for C/C++ APIs which expect the const char* returned from __FILE__ or std::source_location::file_name.
2025-03-06Remove #[cfg(not(test))] gates in coreThalia Archibald-2/+2
These gates are unnecessary now that unit tests for `core` are in a separate package, `coretests`, instead of in the same files as the source code. They previously prevented the two `core` versions from conflicting with each other.
2024-11-27replace placeholder versionBoxy-1/+1
2024-11-03stabilize const_arguments_as_strRalf Jung-2/+1
2024-10-25Re-do recursive const stability checksRalf Jung-0/+1
Fundamentally, we have *three* disjoint categories of functions: 1. const-stable functions 2. private/unstable functions that are meant to be callable from const-stable functions 3. functions that can make use of unstable const features This PR implements the following system: - `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions. - `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category. - `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls. Also, several holes in recursive const stability checking are being closed. There's still one potential hole that is hard to avoid, which is when MIR building automatically inserts calls to a particular function in stable functions -- which happens in the panic machinery. Those need to *not* be `rustc_const_unstable` (or manually get a `rustc_const_stable_indirect`) to be sure they follow recursive const stability. But that's a fairly rare and special case so IMO it's fine. The net effect of this is that a `#[unstable]` or unmarked function can be constified simply by marking it as `const fn`, and it will then be const-callable from stable `const fn` and subject to recursive const stability requirements. If it is publicly reachable (which implies it cannot be unmarked), it will be const-unstable under the same feature gate. Only if the function ever becomes `#[stable]` does it need a `#[rustc_const_unstable]` or `#[rustc_const_stable]` marker to decide if this should also imply const-stability. Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to use unstable const lang features (including intrinsics), or (b) `#[stable]` functions that are not yet intended to be const-stable. Adding `#[rustc_const_stable]` is only needed for functions that are actually meant to be directly callable from stable const code. `#[rustc_const_stable_indirect]` is used to mark intrinsics as const-callable and for `#[rustc_const_unstable]` functions that are actually called from other, exposed-on-stable `const fn`. No other attributes are required.
2024-09-29Rename doctest attribute `standalone-crate` into `standalone_crate` for ↵Guillaume Gomez-1/+1
coherency
2024-09-28Rename `standalone` doctest attribute into `standalone-crate`Guillaume Gomez-1/+1
2024-09-18Auto merge of #129491 - StackOverflowExcept1on:master, r=m-ou-sebors-6/+6
Pass `fmt::Arguments` by reference to `PanicInfo` and `PanicMessage` Resolves #129330 For some reason after #115974 and #126732 optimizations applied to panic handler became worse and compiler stopped removing panic locations if they are not used in the panic message. This PR fixes that and maybe we can merge it into beta before rust 1.81 is released. Note: optimization only works with `lto = "fat"`. r? libs-api
2024-08-25Tweak some attributes to improve panic_immediate_abortBen Kimock-0/+1
2024-08-24Pass `fmt::Arguments` by reference to `PanicInfo` and `PanicMessage`StackOverflowExcept1on-6/+6
2024-08-13Mark location doctest as standalone since file information will not work in ↵Guillaume Gomez-1/+1
merged doctest file
2024-07-30Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68bors-5/+5
Bump bootstrap compiler to new beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-28Update CURRENT_RUSTC_VERSIONMark Rousskov-5/+5
2024-07-26Fix doc nitsJohn Arundel-1/+1
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-06-20Stabilize `PanicInfo::message()` and `PanicMessage`StackOverflowExcept1on-5/+5
2024-06-17Add PanicMessage type for PanicInfo::message().Mara Bos-6/+69
2024-06-12Fix deprecated version.Mara Bos-1/+1
2024-06-12Update doc comment on PanicInfo::message().Mara Bos-3/+2
2024-06-12Fix deprecation version.Mara Bos-1/+1
2024-06-12Clarify doc comment.Mara Bos-1/+1
2024-06-11Fix deprecation version.Mara Bos-1/+1
2024-06-11Rename std::panic::PanicInfo to PanicHookInfo.Mara Bos-12/+8
2024-06-11Remove core::panic::PanicInfo::internal_constructor.Mara Bos-7/+1
It no longer needs to be public.
2024-06-11Add core::panic::PanicInfo::payload() for compatibility.Mara Bos-0/+18
2024-06-11Document difference between core and std's PanicInfo.Mara Bos-0/+9
2024-06-11Split core's PanicInfo and std's PanicInfo.Mara Bos-73/+7
2024-05-01Replace version placeholders for 1.79Mark Rousskov-4/+4
2024-04-06Rollup merge of #122291 - lilasta:stabilize_const_location_fields, r=dtolnayMatthias Krüger-4/+4
Stabilize `const_caller_location` and `const_location_fields` Closes #102911. Closes #76156. tests: [library/core/tests/panic/location.rs](https://github.com/rust-lang/rust/blob/3521a2f2f317cb978063842485c7d1bc86ec82b6/library/core/tests/panic/location.rs) API: ```rust // core::panic::location impl Location { pub const fn caller() -> &'static Location<'static>; pub const fn file(&self) -> &str; pub const fn line(&self) -> u32; pub const fn column(&self) -> u32; } ```
2024-03-23add panic location to 'panicked while processing panic'Ralf Jung-2/+3
2024-03-21Stabilize `const_caller_location` and `const_location_fields`lilasta-4/+4
2024-01-05Replace some usage of `#[rustc_on_unimplemented]` withGeorg Semmler-2/+2
`#[diagnostic::on_unimplemented]` This commit replaces those `#[rustc_on_unimplemented]` attributes with their equivalent `#[diagnostic::on_unimplemented]` where this is supported (So no filter or any extended option)
2023-10-29Increase the reach of panic_immediate_abortBen Kimock-0/+1
2023-08-27avoid triple-backtrace due to panic-during-cleanupRalf Jung-1/+14
2023-07-29Change default panic handler message format.Mara Bos-4/+6
2023-05-15Rollup merge of #108356 - gftea:master, r=workingjubileeMatthias Krüger-1/+1
improve doc test for UnsafeCell::raw_get improve docs of public API `UnsafeCell::raw_get`
2023-04-14Rollup merge of #110110 - lukas-code:display-panic-info, r=JohnTitorMatthias Krüger-6/+2
Use `Display` in top-level example for `PanicInfo` Addresses https://github.com/rust-lang/rust/issues/110098. This confused me as well, when I was writing a `no_std` panic handler for the first time, so here's a better top-level example. `Display` is stable, prints the `.message()` if available, and falls back to `.payload().downcast_ref<&str>()` if the message is not available. So this example should provide strictly more information and also work for formatted panics. The old example still exists on the `payload` method.
2023-04-12Update unwind_safe.rsJustin Symonds-1/+1
Typo in the documentation.
2023-04-09Use `Display` in top-level example for `PanicInfo`Lukas Markeffsky-6/+2
2023-03-10improve doc test for UnsafeCell::raw_get and fix docs errorgftea-1/+1
2022-12-30Replace libstd, libcore, liballoc in line comments.jonathanCogan-1/+1