Align expect messages with guidance - #159998
Conversation
|
|
| //! | ||
| //! let mut file = File::create("valuable_data.txt").unwrap(); | ||
| //! file.write_all(b"important message").expect("failed to write message"); | ||
| //! file.write_all(b"important message").expect("newly created file should be writable"); |
There was a problem hiding this comment.
This is far too specific, you can fail a write for other reasons.
There was a problem hiding this comment.
Changed the message to "writing to the file should succeed". I'm a bit worried that it states the obvious without adding extra context, but since it's just a generic example, I think this should be enough.
| /// ```ignore (hypothetical-example) | ||
| /// loop { | ||
| /// let (client, request) = get_request().expect("disconnected"); | ||
| /// let (client, request) = get_request().expect("server should stay connected while accepting requests"); |
There was a problem hiding this comment.
This line is long enough that the example will get a horizontal scrollbar.
Can you make it shorter?
There was a problem hiding this comment.
Shortened to "server should stay connected"
|
Reminder, once the PR becomes ready for a review, use |
6292ad3 to
e4b881f
Compare
|
@rustbot ready |
|
@bors r+ rollup |
Align expect messages with guidance Issue: rust-lang#159751 - Changed 3 `expect` messages and some relevant comments in `library/core/src/result.rs` and `library/core/src/primitive_docs.rs` - I intentionally left the below snippet unchanged in `library/core/src/result.rs`. The example is quite minimal and focuses on showing the panic output format, so I thought it was better to keep the message short and simple. ``` /// # Panics /// /// Panics if the value is an [`Err`], with a panic message including the /// passed message, and the content of the [`Err`]. /// /// /// # Examples /// /// ```should_panic /// let x: Result<u32, &str> = Err("emergency failure"); /// x.expect("Testing expect"); // panics with `Testing expect: emergency failure` /// ``` ``` r? @fee1-dead
Align expect messages with guidance Issue: rust-lang#159751 - Changed 3 `expect` messages and some relevant comments in `library/core/src/result.rs` and `library/core/src/primitive_docs.rs` - I intentionally left the below snippet unchanged in `library/core/src/result.rs`. The example is quite minimal and focuses on showing the panic output format, so I thought it was better to keep the message short and simple. ``` /// # Panics /// /// Panics if the value is an [`Err`], with a panic message including the /// passed message, and the content of the [`Err`]. /// /// /// # Examples /// /// ```should_panic /// let x: Result<u32, &str> = Err("emergency failure"); /// x.expect("Testing expect"); // panics with `Testing expect: emergency failure` /// ``` ``` r? @fee1-dead
Rollup of 14 pull requests Successful merges: - #159245 (Emit retags in codegen to support BorrowSanitizer (part 5)) - #159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>) - #160079 (make atomic operations const) - #160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s) - #160162 (Make `#[fundamental]` only apply to the first argument of `Box`) - #160210 (Remove an outdated FIXME) - #160282 (Improve diagnostic for patterns in function pointer types) - #157928 (Eagerly fetch typeck results when linting) - #159672 (Improve suggestions when multiples tuples implement the same trait) - #159861 (Add documentation for the `non_exhaustive` attribute) - #159907 (Fix `hidden_glob_reexports` in `rustc_ast`) - #159998 (Align expect messages with guidance) - #160145 (Expand checks for register_tool) - #160307 (Update `minifier` version to `0.4.0`)
Rollup merge of #159998 - pluiee:pluiee/expect-msg, r=fee1-dead Align expect messages with guidance Issue: #159751 - Changed 3 `expect` messages and some relevant comments in `library/core/src/result.rs` and `library/core/src/primitive_docs.rs` - I intentionally left the below snippet unchanged in `library/core/src/result.rs`. The example is quite minimal and focuses on showing the panic output format, so I thought it was better to keep the message short and simple. ``` /// # Panics /// /// Panics if the value is an [`Err`], with a panic message including the /// passed message, and the content of the [`Err`]. /// /// /// # Examples /// /// ```should_panic /// let x: Result<u32, &str> = Err("emergency failure"); /// x.expect("Testing expect"); // panics with `Testing expect: emergency failure` /// ``` ``` r? @fee1-dead
Rollup of 14 pull requests Successful merges: - rust-lang/rust#159245 (Emit retags in codegen to support BorrowSanitizer (part 5)) - rust-lang/rust#159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>) - rust-lang/rust#160079 (make atomic operations const) - rust-lang/rust#160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s) - rust-lang/rust#160162 (Make `#[fundamental]` only apply to the first argument of `Box`) - rust-lang/rust#160210 (Remove an outdated FIXME) - rust-lang/rust#160282 (Improve diagnostic for patterns in function pointer types) - rust-lang/rust#157928 (Eagerly fetch typeck results when linting) - rust-lang/rust#159672 (Improve suggestions when multiples tuples implement the same trait) - rust-lang/rust#159861 (Add documentation for the `non_exhaustive` attribute) - rust-lang/rust#159907 (Fix `hidden_glob_reexports` in `rustc_ast`) - rust-lang/rust#159998 (Align expect messages with guidance) - rust-lang/rust#160145 (Expand checks for register_tool) - rust-lang/rust#160307 (Update `minifier` version to `0.4.0`)
Issue: #159751
Changed 3
expectmessages and some relevant comments inlibrary/core/src/result.rsandlibrary/core/src/primitive_docs.rsI intentionally left the below snippet unchanged in
library/core/src/result.rs.The example is quite minimal and focuses on showing the panic output format, so I thought it was better to keep the message short and simple.
r? @fee1-dead