Skip to content

Useless semicolons #3305

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 Oct 12, 2018 · 6 comments
Closed

Useless semicolons #3305

leonardo-m opened this issue Oct 12, 2018 · 6 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-unnecessary Lint: Warn about unnecessary code

Comments

@leonardo-m
Copy link

leonardo-m commented Oct 12, 2018

I suggest to give some kind of warning or hint to remove the double ;; here:

fn main() {
    println!("hello");;
}

The D language is different from Rust so the situation isn't directly comparable, but in a case like this gives a warning like this:

temp.d(2,22): Warning: use '{ }' for an empty statement, not a ';'

@flip1995 flip1995 added A-lint Area: New lints L-unnecessary Lint: Warn about unnecessary code labels Oct 15, 2018
@estebank
Copy link
Contributor

Adding a different case from rust-lang/rust#56338:

enum Foo { A, B }

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

fn main() {
    bar(Foo::A);
    bar(Foo::B);
}

@leonardo-m
Copy link
Author

In my opinion this is fitter in rustc more than in Clippy. But better to have it in Clippy than having it nowhere.

@JohnTitor
Copy link
Member

The first case is caught by rustc lint (redundant_semicolon) and Clippy lint (clippy::no_effect).

@JohnTitor JohnTitor added C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages and removed A-lint Area: New lints labels Feb 2, 2020
@phansch
Copy link
Member

phansch commented Apr 26, 2020

Shouldn't this be just an extension of the redundant_semicolons lint then? It would feel weird to have clippy::redundant_semicolons and redundant_semicolons in rustc.

@camsteffen
Copy link
Contributor

This applies to anything with a block: if, if let, while, for. I think it should be a separate lint needless_semicolon_after_block.

@dswij
Copy link
Member

dswij commented Jan 10, 2023

There is now a rustc lint redundant_semicolons for this

@dswij dswij closed this as completed Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-unnecessary Lint: Warn about unnecessary code
Projects
None yet
Development

No branches or pull requests

7 participants