-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Raise an error / warning on single path match #12332
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
These are not quite useless with the new lifetime changes, these two statements have different semantic meaning: // this is a compile error
let slot = foo.borrow().get();
// this is valid code
match foo.borrow().get() {
slot => { /* ... */ }
} |
A lint on warn by default (like the other stylistic lints) would be fine for this, no need at all to make it a hard error. (FWIW, using |
As a more general statement, I think that trying to prevent "pointless" code is a non-starter since there is an enormous amount of such code that can be written. There will always be degenerate cases and I don't think we even need a lint. This is unlikely to represent some bug or lead to bugs. Bad style is not necessarily indicative of bad code. If you want to keep your code clean from silly constructs, then don't write them! |
oh mmh, I meant to target this bug just when using It looks like this bug is a dup of #3482 |
@Aatch I don't fully agree and the fact that good and bad style exists is the reason we have lints and style checkers. The whole point is help people to avoid things like this and to avoid writing awful code too. I agree bad style is not indicative of bad code. However, in cases like this it's certainly a waste. |
Coming back to reviewer rotation After this current CPP period, in which I set myself as on-vacation to focus on performance, I'm now available again. I'd love if my vacation status wasn't present in version control changelog:none r? ghost
It is possible to write single path matches, which - although they are correct - are useless (unless I'm missing something). We could catch this cases and raise an error or a warning. I'm personally leaning towards an error, I would prefer keeping the code clean from cases like this.
The text was updated successfully, but these errors were encountered: