-
Notifications
You must be signed in to change notification settings - Fork 13k
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
#[must_use] silently does nothing on type aliases #26281
Comments
Performing As for the type aliases, they always have the exact same behaviour as their original type. If you want different behaviour you must use a newtype. It would be inconsistent to make an exception for |
Alright, let's forget about the type alias case. I still feel that the tuple cast (or any other destructuring assignment) presents a hole in the semantics of |
I’m on the same page as @Thiez. |
The type alias problem here appears to have been discussed and decided on as intentional. The tuple problem is covered by #26291, as far as I can tell, or should be added to that issue and this issue closed. |
Just ran into |
Rebranding this as |
Related/likely-prerequisite: #14407. |
I don't think it would be necessarily inconsistent to make |
As of stable 1.76.0, rustc emits the following warning:
|
There are at least two problems with
#[must_use]
:#[must_use]
type, no warning is issued if the#[must_use]
value is immediately discarded by destructuring assignment at the caller.http://is.gd/TEG45t
Edit: the consensus is that
#[must_use]
should not be usable on type aliases, but it should not just silently fail. The behaviour with destructing assignment is intentional.The text was updated successfully, but these errors were encountered: