Skip to content

Add documentation for the must_use attribute#157957

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
softfault:docs-must-use-attribute
Jun 17, 2026
Merged

Add documentation for the must_use attribute#157957
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
softfault:docs-must-use-attribute

Conversation

@softfault

@softfault softfault commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Document the built-in must_use attribute in the standard library using the #[doc(attribute = "...")] mechanism, following the existing keyword_docs.rs pattern.

Part of #157604.

r? @GuillaumeGomez

Tested with ./x test library/std --doc.

@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 Jun 16, 2026
@rustbot

rustbot commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot

This comment has been minimized.

@softfault softfault force-pushed the docs-must-use-attribute branch from f817c7a to 9624b7f Compare June 16, 2026 10:25
@fmease fmease requested a review from traviscross June 16, 2026 11:10
/// compiler warns through the [`unused_must_use`] lint.
///
/// This is most common on types that represent an important state or outcome. For example,
/// [`Result`] is marked `#[must_use]` because ignoring an error value can hide a failed operation.

@GuillaumeGomez GuillaumeGomez Jun 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a code example illustrating this and also show the compiler message.

View changes since the review

@GuillaumeGomez GuillaumeGomez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Apart the missing code example, looks all good to me, great start!

View changes since this 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 Jun 16, 2026
@rustbot

rustbot commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

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

@softfault

Copy link
Copy Markdown
Contributor Author

Apart the missing code example, looks all good to me, great start!

View changes since this review

:D

@softfault softfault force-pushed the docs-must-use-attribute branch from 9624b7f to 58870a5 Compare June 16, 2026 16:13
Document the built-in `must_use` attribute in the standard library using
the `#[doc(attribute = "...")]` mechanism, following the existing
`keyword_docs.rs` pattern.
@softfault softfault force-pushed the docs-must-use-attribute branch from 58870a5 to 72b3123 Compare June 16, 2026 16:16
@traviscross

traviscross commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

As this is the first, and so will be a kind of template for later ones, @ehuss, I'm particularly interested to hear your thoughts here.

@softfault

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 Jun 17, 2026
@softfault softfault requested a review from GuillaumeGomez June 17, 2026 00:49

@GuillaumeGomez GuillaumeGomez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks all good to me, thanks! I'm gonna let the other two take a look.

View changes since this review

@ehuss

ehuss commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Seems fine to me.

@GuillaumeGomez

Copy link
Copy Markdown
Member

Then let's go!

@bors r=GuillaumeGomez,ehuss rollup

@rust-bors

rust-bors Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 72b3123 has been approved by GuillaumeGomez,ehuss

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 Jun 17, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 17, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #157816 (make more slice mutable ref getters rustc_no_writable)
 - #156788 (Document that destructors in running threads are not run on program exit)
 - #157957 (Add documentation for the `must_use` attribute)
 - #158006 (Simplify `HardwiredLints` and `SoftLints`)
 - #158007 (Pin dependencies)
 - #158025 (Enable `symbol_intern_string_literal` lint for rustdoc)
@traviscross

Copy link
Copy Markdown
Contributor

@bors r=GuillaumeGomez,ehuss,traviscross rollup

@rust-bors

rust-bors Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 72b3123 has been approved by GuillaumeGomez,ehuss,traviscross

It is now in the queue for this repository.

@rust-bors rust-bors Bot merged commit a3bfe01 into rust-lang:main Jun 17, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 17, 2026
rust-timer added a commit that referenced this pull request Jun 17, 2026
Rollup merge of #157957 - softfault:docs-must-use-attribute, r=GuillaumeGomez,ehuss

Add documentation for the `must_use` attribute

Document the built-in `must_use` attribute in the standard library using the `#[doc(attribute = "...")]` mechanism, following the existing `keyword_docs.rs` pattern.

Part of #157604.

r? @GuillaumeGomez

Tested with `./x test library/std --doc`.
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jun 18, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#157816 (make more slice mutable ref getters rustc_no_writable)
 - rust-lang/rust#156788 (Document that destructors in running threads are not run on program exit)
 - rust-lang/rust#157957 (Add documentation for the `must_use` attribute)
 - rust-lang/rust#158006 (Simplify `HardwiredLints` and `SoftLints`)
 - rust-lang/rust#158007 (Pin dependencies)
 - rust-lang/rust#158025 (Enable `symbol_intern_string_literal` lint for rustdoc)
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.

5 participants