-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
pattern binding ****
is named the same as one of the variants of the type SHOULD BE ERROR
#104966
Comments
This is technically valid code due to Rust's existing rules. Issuing a true "hard error" is dubious, because it would be arbitrarily blocking some identifiers from shadowing others in the grammar, which is inconsistent with other rules regarding shadowing: namely, that it is permitted in Rust. However, the relevant lint will already be upgraded to deny-by-default as of #104154 |
Hello Jubilee, thank you for your information. But I thought it should be raised to HUGE warning at least. This "feature" of rust is much inconstant with C/C++/Golang rule which would make lots of trouble by programmers from C/C++/Golang... ^_^ |
Hmm. There are many such footguns if you're expecting a 1:1 match of syntax and semantics with another language, unfortunately, as e.g. this is valid Rust: let x = 5;
let x = 4;
println!("{}", x); This is invalid C++: auto x = 5;
auto x = 4;
std::cout << x; Obviously, we intend to deny the specific case you mention, but it did emit 11 warnings (4 unique)... if the compiler emits 100 warnings, it's technically valid Rust, but that doesn't mean the compiler thought it was a good idea to compile that code. Just that, as far as rustc can tell, it didn't violate memory safety or type soundness. I am curious: is "issuing 11 warnings" somehow not equal to issuing a "huge warning" in your mind? |
The lint will get turned into deny-by-default (error but you can |
I thought |
Hello Jubilee, I know rust is not 1:1 matching indeed. As for this case, I regarding one pare of curly braces behind. What's more, I often use and LOVE this feature of Rust for keeping code clean. In practice, there are so many warning would be generated and no time to eliminate them... For example
So that, the "issuing 11 warnings" will be concealed by the other many warnings in practice.... |
As for the serde struct case, you should use |
Given the following code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=df522ed9839ada9d5c66830e8de12f7c
The current output is:
Ideally the output should look like:
The text was updated successfully, but these errors were encountered: