Add semicolon-outside/inside-block lints by Veykril · Pull Request #9826 · rust-lang/rust-clippy (original) (raw)

@Veykril

It does not trigger in that case no (I added it as to the tests though, thanks for bringing that up)

I think the double semicolon case perfectly fits the lint name semicolon_outside_block, and it's surprising that it fires only when there's no semi inside.

Also I'd expect the following cases to be warn-by-default.

unsafe { foo(); }; // Double semicolon. match foo() { _ => foo() }; // The arm returns (). match foo() { _ => foo(), _ => { foo() } }; // All arms return (). for _ in [()] { unit_fn_block()/semi or no semi/ }; // Always (). if foo() { unit_fn_block()/semi or no semi/ }; // Always (). loop { }; // !

If we want to warn these cases, while still make it configurable for unsafe { f() }; v.s. unsafe { f(); }. Should we create a separated lint for the these warning cases? I cannot come up with another name besides semicolon_outside_block.