Skip to content

Warn for extra semicolon #56338

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

Closed
leonardo-m opened this issue Nov 29, 2018 · 5 comments
Closed

Warn for extra semicolon #56338

leonardo-m opened this issue Nov 29, 2018 · 5 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@leonardo-m
Copy link

leonardo-m commented Nov 29, 2018

The closing semicolon of the match {} is not warned against by Rusts nor Clippy:

enum Foo { A, B }

fn bar(f: Foo) {
    match f {
        Foo::A => {},
        Foo::B => {},
    };
}

fn main() {
    bar(Foo::A);
    bar(Foo::B);
}
@killercup
Copy link
Member

Not sure this is lint-worthy as it doesn't change the semantics of the code. Is it removed by rustfmt?

@leonardo-m
Copy link
Author

Is it removed by rustfmt?

Currently rustfmt doesn't remove it.

Not sure this is lint-worthy as it doesn't change the semantics of the code.

From my experience when the code isn't clean, it could cause troubles for someone later. I prefer Rust code to be tidy, it causes less troubles.

@brunoczim
Copy link

I don't think this should be a rustc's lint. It is an insignificant syntactic detail. There are much worse things like lack of indentation. I don't think we should warn those things either. Maybe it could be a clippy's lint (of pedant category).

Currently, rustfmt cannot remove this extra semicolon because it requires semantical analysis and it only does syntactic analysis. We need to know if the type of the expression is ().

@leonardo-m
Copy link
Author

If that's the consensus I'll move this issue to Clippy issues.

@estebank estebank added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Jan 11, 2019
@estebank
Copy link
Contributor

@leonardo-m closing and linking from similar clippy issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

4 participants