On Oct 17, 2013 8:12 AM, "Patrick Walton" <[email protected]> wrote: > For a long time now I've been wanting to make unused non-unit return values a warning. I think this would be a perfect time to do that...
I would love this to be the case. It's the biggest problem I had with Go's error handling: that it's far too easy to just ignore a return value accidentally. (Truth to tell, the problem is far worse in Go because for some reason they decided you could take not all of the return values, e.g. for a func returning (T, err), `t = f()` will silently discard the err; this has been a decision that has baffled me; I'm glad we have generics and Result and tuples-as-real-types to fix that bad idiom!) Truly explicit is better than implicit. I have three remaining questions on this feature: 1. Is there a functional difference between the lines `let _ = f()` and `let _foo = f()` (assuming no usage of the variable)? These will probably become common if this check is in place. 2. When will Drop happen? I suspect this would make it happen at the end of the callee block, whereas silent ignoring probably before returning execution to the callee? 3. Would such a thing be able to be overridden with something along the lines of #[allow(unused_return_values)]?
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
