about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-02-24 06:56:38 +0000
committerbors <bors@rust-lang.org>2022-02-24 06:56:38 +0000
commit1204400ab8da9830f6f77a5e40e7ad3ea459676a (patch)
tree2e399109ed98d73c5ec75774e88be80bd5d0251f /library/std/src
parente780264e1e5c1efa6ab76c7b17a9677f16add5e0 (diff)
parentbdcdd1b122e3f8994a143de01fef78e265bace21 (diff)
downloadrust-1204400ab8da9830f6f77a5e40e7ad3ea459676a.tar.gz
rust-1204400ab8da9830f6f77a5e40e7ad3ea459676a.zip
Auto merge of #94314 - matthiaskrgr:rollup-hmed8n7, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #89887 (Change `char` type in debuginfo to DW_ATE_UTF)
 - #94267 (Remove unused ordering derivations and bounds for `SimplifiedTypeGen`)
 - #94270 (Miri: relax fn ptr check)
 - #94273 (add matching doc to errorkind)
 - #94283 (remove feature gate in control_flow examples)
 - #94288 (Cleanup a few Decoder methods)
 - #94292 (riscv32imc_esp_espidf: set max_atomic_width to 64)
 - #94296 (:arrow_up: rust-analyzer)
 - #94300 (Fix a typo in documentation of `array::IntoIter::new_unchecked`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/io/error.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs
index 1aa6d657889..17e2b97545a 100644
--- a/library/std/src/io/error.rs
+++ b/library/std/src/io/error.rs
@@ -141,6 +141,19 @@ struct Custom {
 /// It is used with the [`io::Error`] type.
 ///
 /// [`io::Error`]: Error
+///
+/// # Handling errors and matching on `ErrorKind`
+///
+/// In application code, use `match` for the `ErrorKind` values you are
+/// expecting; use `_` to match "all other errors".
+///
+/// In comprehensive and thorough tests that want to verify that a test doesn't
+/// return any known incorrect error kind, you may want to cut-and-paste the
+/// current full list of errors from here into your test code, and then match
+/// `_` as the correct case. This seems counterintuitive, but it will make your
+/// tests more robust. In particular, if you want to verify that your code does
+/// produce an unrecognized error kind, the robust solution is to check for all
+/// the recognized error kinds and fail in those cases.
 #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[allow(deprecated)]