Skip to content

Align expect messages with guidance - #159998

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
pluiee:pluiee/expect-msg
Aug 1, 2026
Merged

Align expect messages with guidance#159998
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
pluiee:pluiee/expect-msg

Conversation

@pluiee

@pluiee pluiee commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 27, 2026
@rustbot

rustbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

fee1-dead is currently at their maximum review capacity.
They may take a while to respond.

Comment thread library/core/src/result.rs Outdated
//!
//! 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");

@mejrs mejrs Jul 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is far too specific, you can fail a write for other reasons.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread library/core/src/primitive_docs.rs Outdated
/// ```ignore (hypothetical-example)
/// loop {
/// let (client, request) = get_request().expect("disconnected");
/// let (client, request) = get_request().expect("server should stay connected while accepting requests");

@mejrs mejrs Jul 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is long enough that the example will get a horizontal scrollbar.
Can you make it shorter?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shortened to "server should stay connected"

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 27, 2026
@rustbot

rustbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@pluiee
pluiee force-pushed the pluiee/expect-msg branch from 6292ad3 to e4b881f Compare July 28, 2026 07:15
@pluiee

pluiee commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 28, 2026
@pluiee
pluiee requested a review from mejrs July 28, 2026 07:20
@fee1-dead

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e4b881f has been approved by fee1-dead

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 31, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 1, 2026
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
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 1, 2026
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
rust-bors Bot pushed a commit that referenced this pull request Aug 1, 2026
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`)
@rust-bors
rust-bors Bot merged commit ab91b74 into rust-lang:main Aug 1, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 1, 2026
rust-timer added a commit that referenced this pull request Aug 1, 2026
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
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Aug 2, 2026
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`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants