Make `;` suggestions inline

This commit is contained in:
Esteban Küber 2024-07-12 03:22:32 +00:00
parent b6f518877f
commit 71f16bdb32
12 changed files with 32 additions and 170 deletions

View File

@ -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),
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -2,27 +2,17 @@ error: expected `;`, found `}`
--> $DIR/missing-semicolon.rs:6:7
|
LL | ()
| ^
| ^ help: add `;` here
LL | }
| - unexpected token
|
help: add `;` here
|
LL | ();
| +
error: expected `;`, found `}`
--> $DIR/missing-semicolon.rs:32:7
|
LL | ()
| ^
| ^ help: add `;` here
LL | }
| - unexpected token
|
help: add `;` here
|
LL | ();
| +
error[E0618]: expected function, found `{integer}`
--> $DIR/missing-semicolon.rs:5:13

View File

@ -2,14 +2,9 @@ error: expected `;`, found `}`
--> $DIR/suggest-semicolon-for-fn-in-extern-block.rs:6:11
|
LL | fn foo()
| ^
| ^ help: add `;` here
LL | }
| - unexpected token
|
help: add `;` here
|
LL | fn foo();
| +
error: aborting due to 1 previous error