Unnecessary ;
WarningSafe fixA ; separates two things on one line that would otherwise need a line break between them: two statements, two fields or methods, two variants, or two match arms, as in let x = 2; print(x * 21). Most other ;s are unnecessary: at the end of a line, at the start of one, right after {, before } or else, at the end of the file, every extra ; in ;;, and after a top-level function, class or enum, which needs no separator before the next item. The program still builds. A ; whose removal would join two lines into one statement stays an error (E0011), as at the start of a line before .f(), and so does a ; where something else must come next, as in let x = ;.
Why
A line break already ends a statement, so a ; there is never needed. Reporting it keeps one way to write a program, and the safe fix removes the ;.
A ; never changes what a block gives. In let y = { x; }, y is still x: the ; does not turn the block's value into unit, as it would in Rust.
Broken
fn main() {
let x = 1;
print(x)
}
What sisu says
warning[W0007]: unnecessary `;` --> W0007.sisu:2:14 | 2 | let x = 1; | ^ | help: remove the `;` | 2 - let x = 1; 2 + let x = 1 | sisu: 1 warning sisu: for more on a code, run `sisu explain <code>`: W0007
Fixed
fn main() {
let x = 1
print(x)
}
Sisu