Mazdak Farrokhzad
|
7178cf5f97
|
Rollup merge of #62984 - nathanwhit:extra_semi_lint, r=varkor
Add lint for excess trailing semicolons
Closes #60876.
A caveat (not necessarily a negative, but something to consider) with this implementation is that excess semicolons after return/continue/break now also cause an 'unreachable statement' warning.
For the following example:
```
fn main() {
extra_semis();
}
fn extra_semis() -> i32 {
let mut sum = 0;;;
for i in 0..10 {
if i == 5 {
continue;;
} else if i == 9 {
break;;
} else {
sum += i;;
}
}
return sum;;
}
```
The output is:
```
warning: unnecessary trailing semicolons
--> src/main.rs:5:21
|
5 | let mut sum = 0;;;
| ^^ help: remove these semicolons
|
= note: `#[warn(redundant_semicolon)]` on by default
warning: unnecessary trailing semicolon
--> src/main.rs:8:22
|
8 | continue;;
| ^ help: remove this semicolon
warning: unnecessary trailing semicolon
--> src/main.rs:10:19
|
10 | break;;
| ^ help: remove this semicolon
warning: unnecessary trailing semicolon
--> src/main.rs:12:22
|
12 | sum += i;;
| ^ help: remove this semicolon
warning: unnecessary trailing semicolon
--> src/main.rs:15:16
|
15 | return sum;;
| ^ help: remove this semicolon
warning: unreachable statement
--> src/main.rs:8:22
|
8 | continue;;
| ^
|
= note: `#[warn(unreachable_code)]` on by default
warning: unreachable statement
--> src/main.rs:10:19
|
10 | break;;
| ^
warning: unreachable statement
--> src/main.rs:15:16
|
15 | return sum;;
| ^
```
|
2019-08-14 22:56:18 +02:00 |
|
Mazdak Farrokhzad
|
a8bb3756b6
|
Rollup merge of #63530 - ehuss:typo-statemement, r=centril
Fix typo in error message.
|
2019-08-14 04:18:57 +02:00 |
|
Eric Huss
|
643ddfaaa8
|
Apply Centril's suggestion
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
|
2019-08-13 15:09:11 -07:00 |
|
Eric Huss
|
ea1a9a0e2b
|
Fix typo in error message.
|
2019-08-13 11:21:09 -07:00 |
|
nathanwhit
|
71415ef9bd
|
Parse excess semicolons as empty stmts for linting
|
2019-08-12 10:14:07 -04:00 |
|
Ilija Tovilo
|
91af5c2daf
|
Bring back suggestion for splitting <- into < -
Closes #62632
|
2019-08-12 10:46:34 +02:00 |
|
Mazdak Farrokhzad
|
bcfcbfc923
|
parser: {check,expect}_lifetime into ty.rs
|
2019-08-11 20:46:34 +02:00 |
|
Mazdak Farrokhzad
|
385d07f359
|
parser: move into generics.rs
|
2019-08-11 20:44:09 +02:00 |
|
Mazdak Farrokhzad
|
d6d93b3d82
|
parser: move into stmt.rs
|
2019-08-11 20:32:29 +02:00 |
|
Mazdak Farrokhzad
|
28db7c5968
|
parser: move parse_fn_block_decl into expr.rs
|
2019-08-11 20:04:09 +02:00 |
|
Mazdak Farrokhzad
|
848ec4aa3c
|
parser: move parse_ident_or_underscore into item.rs
|
2019-08-11 20:00:38 +02:00 |
|
Mazdak Farrokhzad
|
3dbfbafe3e
|
parser: split into {ty, path}.rs
|
2019-08-11 19:59:27 +02:00 |
|
Mazdak Farrokhzad
|
e81347c368
|
parser: split into {item,module}.rs
|
2019-08-11 18:34:42 +02:00 |
|
Mazdak Farrokhzad
|
e742de2569
|
parser: split into pat.rs
|
2019-08-11 15:24:37 +02:00 |
|
Mazdak Farrokhzad
|
81e6b5094e
|
parser: split into expr.rs
|
2019-08-11 13:14:30 +02:00 |
|