Add messages to Option's and Result's must_use annotation for is_*#62431
Merged
bors merged 2 commits intorust-lang:masterfrom Jul 13, 2019
Merged
Add messages to Option's and Result's must_use annotation for is_*#62431bors merged 2 commits intorust-lang:masterfrom
Option's and Result's must_use annotation for is_*#62431bors merged 2 commits intorust-lang:masterfrom
Conversation
Contributor
Author
czipperz
commented
Jul 6, 2019
| /// [`None`]: #variant.None | ||
| #[must_use] | ||
| #[must_use = "if you intended to assert that this doesn't have a value, consider \ | ||
| `.and_then(|| panic!(\"`Option` had a value when expected `None`\"))` instead"] |
Contributor
Author
There was a problem hiding this comment.
I think this message is too long. How about the suggestion is .ok_or(()).unwrap_err()?
Member
There was a problem hiding this comment.
I don't have a strong opinion; I just wanted to give a message as nice as the .unwrap() ones do.
Maybe there's a way to combine them? .ok_or("Option::None").unwrap_err() or similar?
Contributor
Author
There was a problem hiding this comment.
Can we just tell the user to wrap it in an assert!()?
Member
Collaborator
|
📌 Commit 9b0623d has been approved by |
3 tasks
Centril
added a commit
to Centril/rust
that referenced
this pull request
Jul 12, 2019
…s_-methods, r=scottmcm Add messages to `Option`'s and `Result`'s `must_use` annotation for `is_*` r? @RalfJung
bors
added a commit
that referenced
this pull request
Jul 12, 2019
Rollup of 12 pull requests Successful merges: - #61535 (Coherence test when a generic type param has a default value from an associated type) - #62274 (rustc_mir: follow FalseUnwind's real_target edge in qualify_consts.) - #62431 (Add messages to `Option`'s and `Result`'s `must_use` annotation for `is_*`) - #62453 (in which we suggest anonymizing single-use lifetimes in paths ) - #62568 (Replace unsafe_destructor_blind_to_params with may_dangle) - #62578 (Add test for #49919) - #62595 (Document that the crate keyword refers to the project root) - #62599 (move mem::uninitialized deprecation back by 1 release, to 1.39) - #62605 (Emit dropped unemitted errors to aid in ICE debugging) - #62607 (Correctly break out of recovery loop) - #62608 (`async unsafe fn` tests) - #62623 (downgrade indirect_structural_match lint to allow) Failed merges: r? @ghost
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
r? @RalfJung