summary refs log tree commit diff
path: root/library/std/src/panic.rs
AgeCommit message (Collapse)AuthorLines
2023-05-15Shorten lifetime of even more panic temporariesDavid Tolnay-2/+2
2023-05-14Shorten lifetime of panic temporaries in panic_fmt caseDavid Tolnay-1/+3
2023-03-17reviewGus Caplan-1/+1
2023-03-17move default backtrace setting to sysGus Caplan-2/+1
2022-12-28Clarify catch_unwind docs about panic hooksAlbert Larsan-0/+3
Makes it clear from catch_unwind docs that the panic hook will be called before the panic is caught.
2022-09-14Adding backtrace off option for fuchsia targetsAndrew Pollack-17/+16
2022-07-08Support unstable moves via stable in unstable itemsJane Lusby-1/+1
2022-02-02Configure panic hook backtrace behaviorMark Rousskov-0/+114
2022-01-07Implement panic::update_hookBadel2-0/+3
2021-10-19Deduplicate panic_fmtGary Guo-1/+1
std's begin_panic_fmt and core's panic_fmt are duplicates. Merge them to declutter code and remove a lang item.
2021-09-15Allow `panic!("{}", computed_str)` in const fn.Gary Guo-1/+5
2021-07-30Move UnwindSafe, RefUnwindSafe, AssertUnwindSafe to coreDavid Tolnay-309/+4
2021-07-30Auto merge of #87445 - amalik18:issue-83584-fix, r=kennytmbors-2/+2
Fix may not to appropriate might not or must not I went through and changed occurrences of `may not` to be more explicit with `might not` and `must not`.
2021-07-29Fix may not to appropriate might not or must notAli Malik-2/+2
2021-07-28Add new const_format_args!() macro and use it in panics.Mara Bos-2/+2
2021-06-29Use diagnostic items to check for Send, UnwindSafe and RefUnwindSafe traitsRoxane Fruytier-2/+2
2021-06-29Remove lang items Send, UnwindSafe and RefUnwindSafeRoxane Fruytier-2/+2
2021-06-28Update to new bootstrap compilerMark Rousskov-2/+2
2021-05-27Add #[track_caller] to panic_anyAlex Veber-0/+1
2021-05-15Auto merge of #81858 - ijackson:fork-no-unwind, r=m-ou-sebors-0/+36
Do not allocate or unwind after fork ### Objective scenarios * Make (simple) panics safe in `Command::pre_exec_hook`, including most `panic!` calls, `Option::unwrap`, and array bounds check failures. * Make it possible to `libc::fork` and then safely panic in the child (needed for the above, but this requirement means exposing the new raw hook API which the `Command` implementation needs). * In singlethreaded programs, where panic in `pre_exec_hook` is already memory-safe, prevent the double-unwinding malfunction #79740. I think we want to make panic after fork safe even though the post-fork child environment is only experienced by users of `unsafe`, beause the subset of Rust in which any panic is UB is really far too hazardous and unnatural. #### Approach * Provide a way for a program to, at runtime, switch to having panics abort. This makes it possible to panic without making *any* heap allocations, which is needed because on some platforms malloc is UB in a child forked from a multithreaded program (see https://github.com/rust-lang/rust/pull/80263#issuecomment-774272370, and maybe also the SuS [spec](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html)). * Make that change in the child spawned by `Command`. * Document the rules comprehensively enough that a programmer has a fighting chance of writing correct code. * Test that this all works as expected (and in particular, that there aren't any heap allocations we missed) Fixes #79740 #### Rejected (or previously attempted) approaches * Change the panic machinery to be able to unwind without allocating, at least when the payload and message are both `'static`. This seems like it would be even more subtle. Also that is a potentially-hot path which I don't want to mess with. * Change the existing panic hook mechanism to not convert the message to a `String` before calling the hook. This would be a surprising change for existing code and would not be detected by the type system. * Provide a `raw_panic_hook` function to intercept panics in a way that doesn't allocate. (That was an earlier version of this MR.) ### History This MR could be considered a v2 of #80263. Thanks to everyone who commented there. In particular, thanks to `@m-ou-se,` `@Mark-Simulacrum` and `@hyd-dev.` (Tagging you since I think you might be interested in this new MR.) Compared to #80263, this MR has very substantial changes and additions. Additionally, I have recently (2021-04-20) completely revised this series following very helpful comments from `@m-ou-se.` r? `@m-ou-se`
2021-05-11use the correct attributes and add helper functionRoxane-2/+2
2021-05-07std panicking: Provide panic::always_abortIan Jackson-0/+36
We must change the atomic read on panic entry to `Acquire`, to pick up a possible an `always_panic` on another thread. We add `count` to the names of panic_count::get and ::is_zaero, because now there is another reason why panic ought to maybe abort. Renaming these ensures that we have checked every call site to ensure that they don't need further adjustment. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk> Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-06Add additional migrations to handle auto-traits and clone traitsRoxane-0/+2
Combine all 2229 migrations under one flag name
2021-02-13Fixed minor typo in catch_unwind docsVictor Roest-1/+1
Changed 'a an exception' to 'an exception'
2021-02-01Auto merge of #80851 - m-ou-se:panic-2021, r=petrochenkovbors-0/+21
Implement Rust 2021 panic This implements the Rust 2021 versions of `panic!()`. See https://github.com/rust-lang/rust/issues/80162 and https://github.com/rust-lang/rfcs/pull/3007. It does so by replacing `{std, core}::panic!()` by a bulitin macro that expands to either `$crate::panic::panic_2015!(..)` or `$crate::panic::panic_2021!(..)` depending on the edition of the caller. This does not yet make std's panic an alias for core's panic on Rust 2021 as the RFC proposes. That will be a separate change: https://github.com/rust-lang/rust/pull/80879/commits/c5273bdfb266c35e8eab9413aa8d58d27fdbe114 That change is blocked on figuring out what to do with https://github.com/rust-lang/rust/issues/80846 first.
2021-01-30Rollup merge of #79023 - yoshuawuyts:stream, r=KodrAusYuki Okushi-0/+14
Add `core::stream::Stream` [[Tracking issue: #79024](https://github.com/rust-lang/rust/issues/79024)] This patch adds the `core::stream` submodule and implements `core::stream::Stream` in accordance with [RFC2996](https://github.com/rust-lang/rfcs/pull/2996). The RFC hasn't been merged yet, but as requested by the libs team in https://github.com/rust-lang/rfcs/pull/2996#issuecomment-725696389 I'm filing this PR to get the ball rolling. ## Documentatation The docs in this PR have been adapted from [`std::iter`](https://doc.rust-lang.org/std/iter/index.html), [`async_std::stream`](https://docs.rs/async-std/1.7.0/async_std/stream/index.html), and [`futures::stream::Stream`](https://docs.rs/futures/0.3.8/futures/stream/trait.Stream.html). Once this PR lands my plan is to follow this up with PRs to add helper methods such as `stream::repeat` which can be used to document more of the concepts that are currently missing. That will allow us to cover concepts such as "infinite streams" and "laziness" in more depth. ## Feature gate The feature gate for `Stream` is `stream_trait`. This matches the `#[lang = "future_trait"]` attribute name. The intention is that only the APIs defined in RFC2996 will use this feature gate, with future additions such as `stream::repeat` using their own feature gates. This is so we can ensure a smooth path towards stabilizing the `Stream` trait without needing to stabilize all the APIs in `core::stream` at once. But also don't start expanding the API until _after_ stabilization, as was the case with `std::future`. __edit:__ the feature gate has been changed to `async_stream` to match the feature gate proposed in the RFC. ## Conclusion This PR introduces `core::stream::{Stream, Next}` and re-exports it from `std` as `std::stream::{Stream, Next}`. Landing `Stream` in the stdlib has been a mult-year process; and it's incredibly exciting for this to finally happen! --- r? `````@KodrAus````` cc/ `````@rust-lang/wg-async-foundations````` `````@rust-lang/libs`````
2021-01-25Make std::panic_2021 an alias for core::panic_2021.Mara Bos-10/+1
2021-01-25Implement new panic!() behaviour for Rust 2021.Mara Bos-0/+30
2021-01-22Add `core::stream::Stream`Yoshua Wuyts-0/+14
This patch adds the `core::stream` submodule and implements `core::stream::Stream` in accordance with RFC2996. Add feedback from @camelid
2021-01-19Make 'static bound on panic_any explicit.Mara Bos-1/+1
This was already implied because Any: 'static, but this makes it explicit.
2021-01-19Stabilize std::panic::panic_any.Mara Bos-1/+1
2020-10-28Add tracking issue number for panic_any.Mara Bos-1/+1
2020-10-28Update panic_any feature name.Mara Bos-1/+1
Co-authored-by: Camelid <camelidcamel@gmail.com>
2020-10-18Rename panic_box to panic_any.Mara Bos-5/+5
2020-10-18Add std::panic::panic_box.Mara Bos-0/+14
2020-09-25review: fix nits and move panic safety tests to the correct placeAlexis Bourget-0/+3
2020-09-11Mark RefUnwindSafe impls for stable atomic types as stable.Mara Bos-8/+8
These impls were effectively stable. #[unstable] had no effect here, since both RefUnwindSafe and these types were already stable. These effectively became stable as soon as the types became stable, which was in 1.34.0.
2020-08-27Abort when catch_unwind catches a foreign exceptionAmanieu d'Antras-0/+3
2020-08-12Move to intra doc links for ascii.rs and panic.rs, updating the docs a littleAlexis Bourget-17/+0
2020-07-27mv std libs to library/mark-0/+427