Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUpdated RFC #886 with lessons learned from #1812 #1940
Conversation
huonw
and others
added some commits
Feb 19, 2015
This comment has been minimized.
This comment has been minimized.
|
I like the idea in general. But i see two other alternatives:
Have these options been considered? |
This comment has been minimized.
This comment has been minimized.
|
Those are both already implemented, |
This comment has been minimized.
This comment has been minimized.
|
Ah, so IIUC, the argument of this RFC is that there are types for which In reading the RFC, I didn't understand why existing solutions are insufficient... |
This comment has been minimized.
This comment has been minimized.
|
There are quite a lot of APIs that return things you don't always care about, e.g. |
This comment has been minimized.
This comment has been minimized.
|
Ah, ok. That's what I thought, but it's good to be sure Perhaps the RFC can explain this more explicitly. |
This comment has been minimized.
This comment has been minimized.
|
One specific example of why making A similar example against making What this RFC allows for are cases where a function is returning a more general type like those, but you still want to force the user to do something with the result. The example from #1812 is that by applying |
nrc
added
the
T-lang
label
Mar 3, 2017
withoutboats
self-assigned this
Mar 3, 2017
This comment has been minimized.
This comment has been minimized.
|
this typo has enabled an attacker to create 548,000 Zcoins this should motivate this RFC - right now Rust doesn't warn about this |
This comment has been minimized.
This comment has been minimized.
|
Well, actually, the amount of motivation is proportional to the cost of a zcoin Seriously, though, I does anyone know how common such mistakes actually are in the wild? I already agree with the RFC, but I am curious. |
This comment has been minimized.
This comment has been minimized.
|
It is estimated that the attacker made ~$750,000 when he sold his Zcoins. Those are some expensive bugs. |
This comment has been minimized.
This comment has been minimized.
|
@iopq Rather than trying to wrangle merging two PR branches together, I think I want to propose we just merge this branch as RFC 886. However, there are a few more amendments I think it needs to get it in line with the current consensus I'm going to list them as concerns and simultaneously propose a merge of this branch. |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot concern "partial_eq" The detailed design doesn't mention attaching this attribute to |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot concern "Result::ok" The drawback and motivation sections still contain a lot of the original commentary about |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot concern "traits" One thing this RFC doesn't mention is how this plays out with traits and impls - clearly we want to support applying this attribute to trait declarations, but can you apply it to methods in a trait impl block, so that only that particular impl warns? I don't know what implementation concerns that would raise and I'd like to hear from someone about whether or not it would be hard to allow that. |
withoutboats
referenced this pull request
Apr 29, 2017
Closed
Allow `#[must_use]` on functions, rather than just types. Mark `Result::{ok,err}` `#[must_use]`. #886
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 29, 2017
•
|
Team member @withoutboats has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns:
Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
iopq
added some commits
Jun 19, 2017
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jul 6, 2017
|
|
rfcbot
added
the
final-comment-period
label
Jul 6, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jul 16, 2017
|
The final comment period is now complete. |
aturon
referenced this pull request
Jul 17, 2017
Closed
Tracking issue for RFC 1940: allow `#[must_use]` on functions #43302
aturon
merged commit a099f17
into
rust-lang:master
Jul 17, 2017
This comment has been minimized.
This comment has been minimized.
|
Huzzah! This RFC has been merged! Tracking issue. Thanks, everyone who helped push this idea through! |
This comment has been minimized.
This comment has been minimized.
olson-dan
commented
Jul 20, 2017
•
|
I know the final comment period is complete but (Sorry for wading into a pile of well-considered discussion and dropping this, but I feel it's very important for languages that value correctness to have the default behavior of warning on unused return value, which would make things like |
This comment has been minimized.
This comment has been minimized.
ssokolow
commented
Jul 20, 2017
|
If it were changed, I'd recommend something like |
This comment has been minimized.
This comment has been minimized.
olson-dan
commented
Jul 20, 2017
|
If I read your comment right I think it means I wasn't clear... I'm saying that |
This comment has been minimized.
This comment has been minimized.
ssokolow
commented
Jul 20, 2017
•
|
@olson-dan What you're arguing for is implementing full-blown linear typing as a lint and this is the only way that's really a viable option. See The Pain Of Real Linear Types in Rust for details. As for phrasing, my point about intuitiveness still stands. |
This comment has been minimized.
This comment has been minimized.
|
That would be a breaking change anyway & is just not on the table for that reason. |
This comment has been minimized.
This comment has been minimized.
olson-dan
commented
Jul 20, 2017
|
By breaking you mean it would break 1.0 code? If it was not enabled by default it would not. Although it should definitely be default behavior a warning that can be opted-into globally is preferable to local, opt-ins. Or more specifically: I can't rely on developers to locally opt-in to behavior that helps them write code correctly, but I can control compiler options across my organization. This is a major frustration in C++ because "Just add [[nodiscard]] to every function" is not an enforceable solution in that language. Rust is going this route, it seems, and while |
This comment has been minimized.
This comment has been minimized.
|
@olson-dan see the existing |
This comment has been minimized.
This comment has been minimized.
olson-dan
commented
Jul 20, 2017
|
Thanks, that solves it for me. Sorry to derail the issue. |
iopq commentedMar 2, 2017
•
edited
See #886 and #1812
Rendered
Took out
ok()parts