Skip to content

Add some explanations for #[must_use] #50511

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 4 commits into from
May 9, 2018
Merged

Conversation

Manishearth
Copy link
Member

#[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)

@@ -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"]
Copy link
Member

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.

@pietroalbini pietroalbini added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 7, 2018
@QuietMisdreavus
Copy link
Member

r=me pending travis

@QuietMisdreavus
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented May 7, 2018

📌 Commit a72a080 has been approved by QuietMisdreavus

@bors bors 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 May 7, 2018
kennytm added a commit to kennytm/rust that referenced this pull request May 9, 2018
…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.
bors added a commit that referenced this pull request May 9, 2018
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:
@bors bors merged commit a72a080 into rust-lang:master May 9, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants