Skip to content

Add #[must_use] to constructors#697

Merged
clarfonthey merged 2 commits intorust-lang:masterfrom
xtqqczze:must-use-constructors
Feb 28, 2026
Merged

Add #[must_use] to constructors#697
clarfonthey merged 2 commits intorust-lang:masterfrom
xtqqczze:must-use-constructors

Conversation

@xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Feb 27, 2026

@clarfonthey
Copy link
Contributor

clarfonthey commented Feb 28, 2026

Trailing spaces, apparently. Otherwise looks fine.

@xtqqczze

This comment was marked as outdated.

Only the functions that match those in the standard library with `#[must_use]` annotations
@xtqqczze xtqqczze force-pushed the must-use-constructors branch from 2d0db92 to a635266 Compare February 28, 2026 00:21
@xtqqczze xtqqczze changed the title Add #[must_use] to constructors Add #[must_use] to constructors Feb 28, 2026
@xtqqczze

This comment was marked as outdated.

@clarfonthey
Copy link
Contributor

I would be comfortable adding all of those in this PR as well.

#[must_use] is a pretty annoying API IMHO because a lot of these uses feel like places that could be inferred, but since they do noticeably improve diagnostics and are not currently inferrable, we can still add them for now.

@xtqqczze
Copy link
Contributor Author

Pushed changes to add the annotation to similar methods in the standard library that have it, and those added in rust-lang/rust#153204.

@clarfonthey clarfonthey added this pull request to the merge queue Feb 28, 2026
Merged via the queue into rust-lang:master with commit e0a8eb4 Feb 28, 2026
25 checks passed
@xtqqczze xtqqczze deleted the must-use-constructors branch March 1, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants