-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Inconsistency: let mut _ = 0;
is rejected by the parser when let mut _a = 0;
is not
#32501
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
Comments
let mut _ = 0
raises an error when let mut _a = 0
does notlet mut _ = 0
is rejected by the parser when let mut _a = 0
does not
let mut _ = 0
is rejected by the parser when let mut _a = 0
does notlet mut _ = 0;
is rejected by the parser when let mut _a = 0;
is not
|
This is correct, |
Here's an example that shows a clear difference between _ and _s (playground) fn main() {
let s = String::new();
let _ = s; // no op
let _t = s; // move
let _u = s; // ERROR: use of moved value
} |
Yes, Nevertheless I perceive the language design is inconsistent here and scarcely documented. Is it only me who think something has to be improved? |
@bluss Well, in fact let _ = s; // no op This is surprising, but I might have seen a discussion on something like that long before, perhaps in relation to |
Something may be improved, i.e. a custom error message can be issued, but I suppose specialized diagnostics need to be data-driven, i.e. targeted at people en masse and not individuals experimenting in the playpen in the search of consistency :) |
I've added a bit more general diagnostic message in #32506 |
syntax: Extra diagnostics for `_` used in an identifier position Closes #32501
The text was updated successfully, but these errors were encountered: