-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some explanations for #[must_use] #50511
Conversation
src/libcore/result.rs
Outdated
@@ -251,7 +251,7 @@ use ops; | |||
/// [`Ok`]: enum.Result.html#variant.Ok | |||
/// [`Err`]: enum.Result.html#variant.Err | |||
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] | |||
#[must_use] | |||
#[must_use = "this may be an error"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this wording could be clearer (imagine a brand new user indignantly thinking, "You're the compiler; you should know whether it's a compilation error or not"), but I'm not sure what exact phrasing to suggest instead; "this Result
may be an Err
variant" may be too jargony.
r=me pending travis |
@bors r+ rollup |
📌 Commit a72a080 has been approved by |
…avus Add some explanations for #[must_use] `#[must_use]` can be given a string argument which is shown whilst warning for things. We should add a string argument to most of the user-exposed ones. I added these for everything but the operators, mostly because I'm not sure what to write there or if we need anything there.
Rollup of 11 pull requests Successful merges: - #49988 (Mention Result<!, E> in never docs.) - #50148 (turn `ManuallyDrop::new` into a constant function) - #50456 (Update the Cargo submodule) - #50460 (Make `String::new()` const) - #50464 (Remove some transmutes) - #50505 (Added regression function match value test) - #50511 (Add some explanations for #[must_use]) - #50525 (Optimize string handling in lit_token().) - #50527 (Cleanup a `use` in a raw_vec test) - #50539 (Add more logarithm constants) - #49523 (Update RELEASES.md for 1.26.0) Failed merges:
#[must_use]
can be given a string argument which is shown whilst warning for things.We should add a string argument to most of the user-exposed ones.
I added these for everything but the operators, mostly because I'm not sure what to write there or if we need anything there.
r? @imperio @QuietMisdreavus
(I consider this to be a docs/diagnostics issue)