about summary refs log tree commit diff
path: root/library/std/src/error.rs
AgeCommit message (Collapse)AuthorLines
2025-01-26Move std::error unit tests to integration testsbjorn3-3/+0
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-08-02chore: refactor backtrace formattingKonippi-7/+2
2024-07-29Reformat `use` declarations.Nicholas Nethercote-3/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
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-16std: move `sys_common::backtrace` to `sys`joboet-1/+1
2023-11-26Clean dead codesr0cky-8/+0
2023-08-18Expose core::error::request_value in stdJake Goulding-1/+1
I think this was simply forgotten in #113464.
2023-08-13core/any: remove Provider traitwayne warren-6/+7
* remove `impl Provider for Error` * rename `Demand` to `Request` * update docstrings to focus on the conceptual API provided by `Request` * move `core::any::{request_ref, request_value}` functions into `core::error` * move `core::any::tag`, `core::any::Request`, an `core::any::TaggedOption` into `core::error` * replace `provide_any` feature name w/ `error_generic_member_access` * move `core::error::request_{ref,value} tests into core::tests::error module * update unit and doc tests
2023-07-29Change default panic handler message format.Mara Bos-1/+2
2022-09-26remove cfg(bootstrap)Pietro Albini-1023/+0
2022-08-25error::Error: remove some commentsNick Cameron-15/+0
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-24error::Error: rename the Demand arguments from req to demandNick Cameron-12/+11
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-24error::Error: rename the chain method to sourcesNick Cameron-13/+28
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-22Move error trait into coreJane Losare-Lusby-226/+81
2022-08-20Improve primitive/std docs separation and headersCameron Steffen-1/+1
2022-08-02Stabilize backtraceTheodore Dubois-1/+0
2022-08-01remove fn backtraceJane Losare-Lusby-41/+33
2022-07-15add tracking issue to generic member access APIsJane Losare-Lusby-8/+8
2022-07-11apply suggestions from code reviewJane Losare-Lusby-7/+8
2022-06-13fix broken doc commentJane Lusby-9/+10
2022-06-13remove outdated referencesJane Lusby-2/+1
2022-06-13Add provider API to error traitJane Lusby-1/+115
2022-05-29Fix typo (panick -> panic)Maybe Waffle-1/+1
2022-05-26Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcmMatthias Krüger-1/+137
Add section on common message styles for Result::expect Based on a question from https://github.com/rust-lang/project-error-handling/issues/50#issuecomment-1092339937 ~~One thing I haven't decided on yet, should I duplicate this section on `Option::expect`, link to this section, or move it somewhere else and link to that location from both docs?~~: I ended up moving the section to `std::error` and referencing it from both `Result::expect` and `Option::expect`'s docs. I think this section, when combined with the similar update I made on [`std::panic!`](https://doc.rust-lang.org/nightly/std/macro.panic.html#when-to-use-panic-vs-result) implies that we should possibly more aggressively encourage and support the "expect as precondition" style described in this section. The consensus among the libs team seems to be that panic should be used for bugs, not expected potential failure modes. The "expect as error message" style seems to align better with the panic for unrecoverable errors style where they're seen as normal errors where the only difference is a desire to kill the current execution unit (aka erlang style error handling). I'm wondering if we should be providing a panic hook similar to `human-panic` or more strongly recommending the "expect as precondition" style of expect message.
2022-05-25fix linksJane Lusby-11/+13
2022-05-24explained unwrap vs expectJane Losare-Lusby-12/+15
2022-05-18Fix rusty grammar in `std::error::Reporter` docsSam Robinson-Adams-4/+4
I initially saw "print's" instead of "prints" at the start of the doc comment for `std::error::Reporter`, while reading the docs for that type. Then I figured 'probably more where that came from', so, as well as correcting the foregoing to "prints", I've patched up these three minor solecisms (well, two [types](https://en.wikipedia.org/wiki/Type%E2%80%93token_distinction), three [tokens](https://en.wikipedia.org/wiki/Type%E2%80%93token_distinction)): - One use of the indicative which should be subjunctive - indeed the sentence immediately following it, which mirrors its structure, _does_ use the subjunctive ([L871](https://github.com/rust-lang/rust/blob/master/library/std/src/error.rs?plain=1#L871)). Replaced with the subjunctive. - Two separate clauses joined with commas ([L975](https://github.com/rust-lang/rust/blob/master/library/std/src/error.rs?plain=1#L975), [L1023](https://github.com/rust-lang/rust/blob/master/library/std/src/error.rs?plain=1#L1023)). Replaced the first with a semicolon and the second with a period. Admittedly those judgements are pretty much 100% subjective, based on my sense of how the sentences flowed into each other (though ofc the _replacement of the comma itself_ is not subjective or opinion-based). I know this is silly and finicky, but I hope it helps tidy up the docs a bit for future readers!
2022-05-09Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errorsbors-3/+3
Remove `#[rustc_deprecated]` This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`. I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2022-05-06This is a pretty good start if you ask meJane Lusby-1/+132
2022-04-28Add more diagnostic itemsSerial-0/+1
2022-04-14library: Move `CStr` to libcore, and `CString` to liballocVadim Petrochenkov-0/+43
2022-04-14Remove use of `#[rustc_deprecated]`Jacob Pratt-3/+3
2022-04-08Add ThinBox type for 1 stack pointer sized heap allocated trait objectsJane Lusby-0/+8
Relevant commit messages from squashed history in order: Add initial version of ThinBox update test to actually capture failure swap to middle ptr impl based on matthieu-m's design Fix stack overflow in debug impl The previous version would take a `&ThinBox<T>` and deref it once, which resulted in a no-op and the same type, which it would then print causing an endless recursion. I've switched to calling `deref` by name to let method resolution handle deref the correct number of times. I've also updated the Drop impl for good measure since it seemed like it could be falling prey to the same bug, and I'll be adding some tests to verify that the drop is happening correctly. add test to verify drop is behaving add doc examples and remove unnecessary Pointee bounds ThinBox: use NonNull ThinBox: tests for size Apply suggestions from code review Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com> use handle_alloc_error and fix drop signature update niche and size tests add cfg for allocating APIs check null before calculating offset add test for zst and trial usage prevent optimizer induced ub in drop and cleanup metadata gathering account for arbitrary size and alignment metadata Thank you nika and thomcc! Update library/alloc/src/boxed/thin.rs Co-authored-by: Josh Triplett <josh@joshtriplett.org> Update library/alloc/src/boxed/thin.rs Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-13/+13
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-01-26Improve Duration::try_from_secs_f32/64 accuracy by directly processing ↵Артём Павлов [Artyom Pavlov]-1/+1
exponent and mantissa
2022-01-13Rollup merge of #91938 - yaahc:error-reporter, r=m-ou-seMatthias Krüger-4/+643
Add `std::error::Report` type This is a continuation of https://github.com/rust-lang/rust/pull/90174, split into a separate PR since I cannot push to ```````@seanchen1991``````` 's fork
2022-01-10Eliminate "boxed" wording in `std::error::Error` documentationdavid-perez-6/+6
In commit 29403ee, documentation for the methods on `std::any::Any` was modified so that they referred to the concrete value behind the trait object as the "inner" value. This is a more accurate wording than "boxed": while putting trait objects inside boxes is arguably the most common use, they can also be placed behind other pointer types like `&mut` or `std::sync::Arc`. This commit does the same documentation changes for `std::error::Error`.
2022-01-07silence tidy errorsJane Lusby-10/+4
2022-01-07Implement `TryFrom<char>` for `u8`Ian Douglas Scott-0/+3
Previously suggested in https://github.com/rust-lang/rfcs/issues/2854. It makes sense to have this since `char` implements `From<u8>`. Likewise `u32`, `u64`, and `u128` (since #79502) implement `From<char>`.
2021-12-16attempt to make Report usable with Box dyn Error and fn mainJane Lusby-103/+201
2021-12-16more docs improvementsJane Lusby-35/+207
2021-12-16add a panicking exampleJane Lusby-4/+51
2021-12-16Update report output and fix examplesJane Lusby-35/+160
2021-12-14Update std::error::Report based on feedbackJane Lusby-27/+47
2021-10-27Fix broken doctestSean Chen-2/+2
2021-10-27Format doctestSean Chen-45/+10
2021-10-27Add `rust` annotation to doctestSean Chen-1/+1
2021-10-27Attempt to fix tidy errorsSean Chen-79/+54
2021-10-22Change `source` field to `error`Sean Chen-8/+8