Skip to content

Align expect messages with guidance - #159998

Open
pluiee wants to merge 1 commit into
rust-lang:mainfrom
pluiee:pluiee/expect-msg
Open

Align expect messages with guidance#159998
pluiee wants to merge 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.

//!
//! 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

/// ```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

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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