rust/src/libsyntax/parse/parser
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
..
expr.rs Rollup merge of #63530 - ehuss:typo-statemement, r=centril 2019-08-14 04:18:57 +02:00
generics.rs parser: move into generics.rs 2019-08-11 20:44:09 +02:00
item.rs parser: move into stmt.rs 2019-08-11 20:32:29 +02:00
module.rs parser: split into {item,module}.rs 2019-08-11 18:34:42 +02:00
pat.rs parser: split into pat.rs 2019-08-11 15:24:37 +02:00
path.rs parser: move into stmt.rs 2019-08-11 20:32:29 +02:00
stmt.rs Parse excess semicolons as empty stmts for linting 2019-08-12 10:14:07 -04:00
ty.rs parser: {check,expect}_lifetime into ty.rs 2019-08-11 20:46:34 +02:00