-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Unused variables lead to scary diagnostics #18159
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
cc @nick29581 |
Jakub, not sure what exactly you mean by "scary" for the error that the compiler returns. But I do know that it isn't because x is unused. It's because it isn't declared correctly. Because Rust is a systems level language all variables have to be a known type so that the compiler known how much memory space is needed. A safety feature of Rust is also that it tracks type to make sure that you don't try to set an integer variable to something other than an integer. Rust is after all a strongly typed language and so whatever type you declare a variable to be that's the only kind of data it can have. You may want to check out the guide here: It actually lists this error as an example. |
@code-ape The message in the guide is out of date. The one I provided in the original report is what I considered "scary". |
This related to #17567, where we decided we should just give a better error message. Here it seems that type inference could do better - if Aside: this would be a cleaner way to implement the check that local vars are sized, but we would have to require that the Sized bound is a requirement of any type, since I believe unifying |
The text was updated successfully, but these errors were encountered: