Skip to content

Commit

Permalink
Make ; suggestions inline
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jul 12, 2024
1 parent b6f5188 commit 71f16bd
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 170 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,14 +1215,14 @@ pub(crate) enum ExpectedSemiSugg {
parse_sugg_change_this_to_semi,
code = ";",
applicability = "machine-applicable",
style = "verbose"
style = "short"
)]
ChangeToSemi(#[primary_span] Span),
#[suggestion(
parse_sugg_add_semi,
style = "verbose",
code = ";",
applicability = "machine-applicable"
applicability = "machine-applicable",
style = "short"
)]
AddSemi(#[primary_span] Span),
}
Expand Down
14 changes: 2 additions & 12 deletions tests/ui/let-else/let-else-missing-semicolon.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,17 @@ error: expected `;`, found keyword `let`
--> $DIR/let-else-missing-semicolon.rs:4:6
|
LL | }
| ^
| ^ help: add `;` here
LL | let _ = "";
| --- unexpected token
|
help: add `;` here
|
LL | };
| +

error: expected `;`, found `}`
--> $DIR/let-else-missing-semicolon.rs:8:6
|
LL | }
| ^
| ^ help: add `;` here
LL | }
| - unexpected token
|
help: add `;` here
|
LL | };
| +

error: aborting due to 2 previous errors

21 changes: 3 additions & 18 deletions tests/ui/parser/issues/issue-103425.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,28 @@ error: expected `;`, found `5.0`
--> $DIR/issue-103425.rs:2:6
|
LL | 3
| ^
| ^ help: add `;` here
LL |
LL | 5.0
| --- unexpected token
|
help: add `;` here
|
LL | 3;
| +

error: expected `;`, found `3_i8`
--> $DIR/issue-103425.rs:8:10
|
LL | 2_u32
| ^
| ^ help: add `;` here
LL |
LL | 3_i8
| ---- unexpected token
|
help: add `;` here
|
LL | 2_u32;
| +

error: expected `;`, found `5.0`
--> $DIR/issue-103425.rs:10:9
|
LL | 3_i8
| ^
| ^ help: add `;` here
LL |
LL | 5.0
| --- unexpected token
|
help: add `;` here
|
LL | 3_i8;
| +

error: aborting due to 3 previous errors

7 changes: 2 additions & 5 deletions tests/ui/parser/issues/issue-118530-ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ LL | #[feature]
| ---------- only `;` terminated statements or tail expressions are allowed after this attribute
LL | attr::fn bar() -> String {
| ^--- unexpected token
|
help: add `;` here
|
LL | attr::fn; bar() -> String {
| +
| |
| help: add `;` here

error: `->` used for field access or method call
--> $DIR/issue-118530-ice.rs:5:20
Expand Down
7 changes: 1 addition & 6 deletions tests/ui/parser/issues/issue-3036.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ error: expected `;`, found `}`
--> $DIR/issue-3036.rs:6:15
|
LL | let _x = 3
| ^
| ^ help: add `;` here
LL | }
| - unexpected token
|
help: add `;` here
|
LL | let _x = 3;
| +

error: aborting due to 1 previous error

21 changes: 3 additions & 18 deletions tests/ui/parser/issues/issue-87197-missing-semicolon.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,25 @@ error: expected `;`, found `println`
--> $DIR/issue-87197-missing-semicolon.rs:6:16
|
LL | let x = 100
| ^
| ^ help: add `;` here
LL | println!("{}", x)
| ------- unexpected token
|
help: add `;` here
|
LL | let x = 100;
| +

error: expected `;`, found keyword `let`
--> $DIR/issue-87197-missing-semicolon.rs:7:22
|
LL | println!("{}", x)
| ^
| ^ help: add `;` here
LL | let y = 200
| --- unexpected token
|
help: add `;` here
|
LL | println!("{}", x);
| +

error: expected `;`, found `println`
--> $DIR/issue-87197-missing-semicolon.rs:8:16
|
LL | let y = 200
| ^
| ^ help: add `;` here
LL | println!("{}", y);
| ------- unexpected token
|
help: add `;` here
|
LL | let y = 200;
| +

error: aborting due to 3 previous errors

14 changes: 2 additions & 12 deletions tests/ui/parser/macros-no-semicolon.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,17 @@ error: expected `;`, found `assert_eq`
--> $DIR/macros-no-semicolon.rs:2:21
|
LL | assert_eq!(1, 2)
| ^
| ^ help: add `;` here
LL | assert_eq!(3, 4)
| --------- unexpected token
|
help: add `;` here
|
LL | assert_eq!(1, 2);
| +

error: expected `;`, found `println`
--> $DIR/macros-no-semicolon.rs:3:21
|
LL | assert_eq!(3, 4)
| ^
| ^ help: add `;` here
LL | println!("hello");
| ------- unexpected token
|
help: add `;` here
|
LL | assert_eq!(3, 4);
| +

error: aborting due to 2 previous errors

7 changes: 1 addition & 6 deletions tests/ui/parser/raw/raw-str-unbalanced.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ error: expected `;`, found `#`
--> $DIR/raw-str-unbalanced.rs:10:28
|
LL | const A: &'static str = r""
| ^
| ^ help: add `;` here
...
LL | #[test]
| - unexpected token
|
help: add `;` here
|
LL | const A: &'static str = r"";
| +

error: too many `#` when terminating raw string
--> $DIR/raw-str-unbalanced.rs:16:28
Expand Down
70 changes: 10 additions & 60 deletions tests/ui/parser/recover/recover-missing-semi-before-item.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,132 +2,82 @@ 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
|
help: add `;` here
|
LL | let foo = 3;
| +

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
|
help: add `;` here
|
LL | let foo = 3;
| +

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
|
help: add `;` here
|
LL | let foo = 3;
| +

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
|
help: add `;` here
|
LL | let foo = 3;
| +

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
|
help: add `;` here
|
LL | let foo = 3;
| +

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
|
help: add `;` here
|
LL | let foo = 3;
| +

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
|
help: add `;` here
|
LL | let foo = 3;
| +

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
|
help: add `;` here
|
LL | let foo = 3;
| +

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
|
help: add `;` here
|
LL | let foo = 3;
| +

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
|
help: add `;` here
|
LL | const X: i32 = 123;
| +

error: aborting due to 10 previous errors

14 changes: 2 additions & 12 deletions tests/ui/parser/recover/recover-missing-semi.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,19 @@ error: expected `;`, found keyword `let`
--> $DIR/recover-missing-semi.rs:2:22
|
LL | let _: usize = ()
| ^
| ^ help: add `;` here
...
LL | let _ = 3;
| --- unexpected token
|
help: add `;` here
|
LL | let _: usize = ();
| +

error: expected `;`, found keyword `return`
--> $DIR/recover-missing-semi.rs:9:22
|
LL | let _: usize = ()
| ^
| ^ help: add `;` here
...
LL | return 3;
| ------ unexpected token
|
help: add `;` here
|
LL | let _: usize = ();
| +

error[E0308]: mismatched types
--> $DIR/recover-missing-semi.rs:2:20
Expand Down
Loading

0 comments on commit 71f16bd

Please sign in to comment.