forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#100565 - TaKO8Ki:suggest-adding-missing-sem…
…icolon-before-item, r=compiler-errors Suggest adding a missing semicolon before an item fixes rust-lang#100533
- Loading branch information
Showing
5 changed files
with
233 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused_variables, dead_code)] | ||
|
||
fn for_struct() { | ||
let foo = 3; //~ ERROR expected `;`, found keyword `struct` | ||
struct Foo; | ||
} | ||
|
||
fn for_union() { | ||
let foo = 3; //~ ERROR expected `;`, found `union` | ||
union Foo { | ||
foo: usize, | ||
} | ||
} | ||
|
||
fn for_enum() { | ||
let foo = 3; //~ ERROR expected `;`, found keyword `enum` | ||
enum Foo { | ||
Bar, | ||
} | ||
} | ||
|
||
fn for_fn() { | ||
let foo = 3; //~ ERROR expected `;`, found keyword `fn` | ||
fn foo() {} | ||
} | ||
|
||
fn for_extern() { | ||
let foo = 3; //~ ERROR expected `;`, found keyword `extern` | ||
extern fn foo() {} | ||
} | ||
|
||
fn for_impl() { | ||
struct Foo; | ||
let foo = 3; //~ ERROR expected `;`, found keyword `impl` | ||
impl Foo {} | ||
} | ||
|
||
fn for_use() { | ||
let foo = 3; //~ ERROR expected `;`, found keyword `pub` | ||
pub use bar::Bar; | ||
} | ||
|
||
fn for_mod() { | ||
let foo = 3; //~ ERROR expected `;`, found keyword `mod` | ||
mod foo {} | ||
} | ||
|
||
fn for_type() { | ||
let foo = 3; //~ ERROR expected `;`, found keyword `type` | ||
type Foo = usize; | ||
} | ||
|
||
mod bar { | ||
pub struct Bar; | ||
} | ||
|
||
const X: i32 = 123; //~ ERROR expected `;`, found keyword `fn` | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused_variables, dead_code)] | ||
|
||
fn for_struct() { | ||
let foo = 3 //~ ERROR expected `;`, found keyword `struct` | ||
struct Foo; | ||
} | ||
|
||
fn for_union() { | ||
let foo = 3 //~ ERROR expected `;`, found `union` | ||
union Foo { | ||
foo: usize, | ||
} | ||
} | ||
|
||
fn for_enum() { | ||
let foo = 3 //~ ERROR expected `;`, found keyword `enum` | ||
enum Foo { | ||
Bar, | ||
} | ||
} | ||
|
||
fn for_fn() { | ||
let foo = 3 //~ ERROR expected `;`, found keyword `fn` | ||
fn foo() {} | ||
} | ||
|
||
fn for_extern() { | ||
let foo = 3 //~ ERROR expected `;`, found keyword `extern` | ||
extern fn foo() {} | ||
} | ||
|
||
fn for_impl() { | ||
struct Foo; | ||
let foo = 3 //~ ERROR expected `;`, found keyword `impl` | ||
impl Foo {} | ||
} | ||
|
||
fn for_use() { | ||
let foo = 3 //~ ERROR expected `;`, found keyword `pub` | ||
pub use bar::Bar; | ||
} | ||
|
||
fn for_mod() { | ||
let foo = 3 //~ ERROR expected `;`, found keyword `mod` | ||
mod foo {} | ||
} | ||
|
||
fn for_type() { | ||
let foo = 3 //~ ERROR expected `;`, found keyword `type` | ||
type Foo = usize; | ||
} | ||
|
||
mod bar { | ||
pub struct Bar; | ||
} | ||
|
||
const X: i32 = 123 //~ ERROR expected `;`, found keyword `fn` | ||
|
||
fn main() {} |
83 changes: 83 additions & 0 deletions
83
src/test/ui/parser/recover-missing-semi-before-item.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
error: expected `;`, found keyword `struct` | ||
--> $DIR/recover-missing-semi-before-item.rs:6:16 | ||
| | ||
LL | let foo = 3 | ||
| ^ help: add `;` here | ||
LL | struct Foo; | ||
| ------ unexpected token | ||
|
||
error: expected `;`, found `union` | ||
--> $DIR/recover-missing-semi-before-item.rs:11:16 | ||
| | ||
LL | let foo = 3 | ||
| ^ help: add `;` here | ||
LL | union Foo { | ||
| ----- unexpected token | ||
|
||
error: expected `;`, found keyword `enum` | ||
--> $DIR/recover-missing-semi-before-item.rs:18:16 | ||
| | ||
LL | let foo = 3 | ||
| ^ help: add `;` here | ||
LL | enum Foo { | ||
| ---- unexpected token | ||
|
||
error: expected `;`, found keyword `fn` | ||
--> $DIR/recover-missing-semi-before-item.rs:25:16 | ||
| | ||
LL | let foo = 3 | ||
| ^ help: add `;` here | ||
LL | fn foo() {} | ||
| -- unexpected token | ||
|
||
error: expected `;`, found keyword `extern` | ||
--> $DIR/recover-missing-semi-before-item.rs:30:16 | ||
| | ||
LL | let foo = 3 | ||
| ^ help: add `;` here | ||
LL | extern fn foo() {} | ||
| ------ unexpected token | ||
|
||
error: expected `;`, found keyword `impl` | ||
--> $DIR/recover-missing-semi-before-item.rs:36:16 | ||
| | ||
LL | let foo = 3 | ||
| ^ help: add `;` here | ||
LL | impl Foo {} | ||
| ---- unexpected token | ||
|
||
error: expected `;`, found keyword `pub` | ||
--> $DIR/recover-missing-semi-before-item.rs:41:16 | ||
| | ||
LL | let foo = 3 | ||
| ^ help: add `;` here | ||
LL | pub use bar::Bar; | ||
| --- unexpected token | ||
|
||
error: expected `;`, found keyword `mod` | ||
--> $DIR/recover-missing-semi-before-item.rs:46:16 | ||
| | ||
LL | let foo = 3 | ||
| ^ help: add `;` here | ||
LL | mod foo {} | ||
| --- unexpected token | ||
|
||
error: expected `;`, found keyword `type` | ||
--> $DIR/recover-missing-semi-before-item.rs:51:16 | ||
| | ||
LL | let foo = 3 | ||
| ^ help: add `;` here | ||
LL | type Foo = usize; | ||
| ---- unexpected token | ||
|
||
error: expected `;`, found keyword `fn` | ||
--> $DIR/recover-missing-semi-before-item.rs:59:19 | ||
| | ||
LL | const X: i32 = 123 | ||
| ^ help: add `;` here | ||
LL | | ||
LL | fn main() {} | ||
| -- unexpected token | ||
|
||
error: aborting due to 10 previous errors | ||
|