1
Fork 0

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, parse_sugg_change_this_to_semi,
code = ";", code = ";",
applicability = "machine-applicable", applicability = "machine-applicable",
style = "verbose" style = "short"
)] )]
ChangeToSemi(#[primary_span] Span), ChangeToSemi(#[primary_span] Span),
#[suggestion( #[suggestion(
parse_sugg_add_semi, parse_sugg_add_semi,
style = "verbose",
code = ";", code = ";",
applicability = "machine-applicable" applicability = "machine-applicable",
style = "short"
)] )]
AddSemi(#[primary_span] Span), AddSemi(#[primary_span] Span),
} }

View file

@ -2,27 +2,17 @@ error: expected `;`, found keyword `let`
--> $DIR/let-else-missing-semicolon.rs:4:6 --> $DIR/let-else-missing-semicolon.rs:4:6
| |
LL | } LL | }
| ^ | ^ help: add `;` here
LL | let _ = ""; LL | let _ = "";
| --- unexpected token | --- unexpected token
|
help: add `;` here
|
LL | };
| +
error: expected `;`, found `}` error: expected `;`, found `}`
--> $DIR/let-else-missing-semicolon.rs:8:6 --> $DIR/let-else-missing-semicolon.rs:8:6
| |
LL | } LL | }
| ^ | ^ help: add `;` here
LL | } LL | }
| - unexpected token | - unexpected token
|
help: add `;` here
|
LL | };
| +
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -2,43 +2,28 @@ error: expected `;`, found `5.0`
--> $DIR/issue-103425.rs:2:6 --> $DIR/issue-103425.rs:2:6
| |
LL | 3 LL | 3
| ^ | ^ help: add `;` here
LL | LL |
LL | 5.0 LL | 5.0
| --- unexpected token | --- unexpected token
|
help: add `;` here
|
LL | 3;
| +
error: expected `;`, found `3_i8` error: expected `;`, found `3_i8`
--> $DIR/issue-103425.rs:8:10 --> $DIR/issue-103425.rs:8:10
| |
LL | 2_u32 LL | 2_u32
| ^ | ^ help: add `;` here
LL | LL |
LL | 3_i8 LL | 3_i8
| ---- unexpected token | ---- unexpected token
|
help: add `;` here
|
LL | 2_u32;
| +
error: expected `;`, found `5.0` error: expected `;`, found `5.0`
--> $DIR/issue-103425.rs:10:9 --> $DIR/issue-103425.rs:10:9
| |
LL | 3_i8 LL | 3_i8
| ^ | ^ help: add `;` here
LL | LL |
LL | 5.0 LL | 5.0
| --- unexpected token | --- unexpected token
|
help: add `;` here
|
LL | 3_i8;
| +
error: aborting due to 3 previous errors 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 | ---------- only `;` terminated statements or tail expressions are allowed after this attribute
LL | attr::fn bar() -> String { LL | attr::fn bar() -> String {
| ^--- unexpected token | ^--- unexpected token
| | |
help: add `;` here | help: add `;` here
|
LL | attr::fn; bar() -> String {
| +
error: `->` used for field access or method call error: `->` used for field access or method call
--> $DIR/issue-118530-ice.rs:5:20 --> $DIR/issue-118530-ice.rs:5:20

View file

@ -2,14 +2,9 @@ error: expected `;`, found `}`
--> $DIR/issue-3036.rs:6:15 --> $DIR/issue-3036.rs:6:15
| |
LL | let _x = 3 LL | let _x = 3
| ^ | ^ help: add `;` here
LL | } LL | }
| - unexpected token | - unexpected token
|
help: add `;` here
|
LL | let _x = 3;
| +
error: aborting due to 1 previous error 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 --> $DIR/issue-87197-missing-semicolon.rs:6:16
| |
LL | let x = 100 LL | let x = 100
| ^ | ^ help: add `;` here
LL | println!("{}", x) LL | println!("{}", x)
| ------- unexpected token | ------- unexpected token
|
help: add `;` here
|
LL | let x = 100;
| +
error: expected `;`, found keyword `let` error: expected `;`, found keyword `let`
--> $DIR/issue-87197-missing-semicolon.rs:7:22 --> $DIR/issue-87197-missing-semicolon.rs:7:22
| |
LL | println!("{}", x) LL | println!("{}", x)
| ^ | ^ help: add `;` here
LL | let y = 200 LL | let y = 200
| --- unexpected token | --- unexpected token
|
help: add `;` here
|
LL | println!("{}", x);
| +
error: expected `;`, found `println` error: expected `;`, found `println`
--> $DIR/issue-87197-missing-semicolon.rs:8:16 --> $DIR/issue-87197-missing-semicolon.rs:8:16
| |
LL | let y = 200 LL | let y = 200
| ^ | ^ help: add `;` here
LL | println!("{}", y); LL | println!("{}", y);
| ------- unexpected token | ------- unexpected token
|
help: add `;` here
|
LL | let y = 200;
| +
error: aborting due to 3 previous errors 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 --> $DIR/macros-no-semicolon.rs:2:21
| |
LL | assert_eq!(1, 2) LL | assert_eq!(1, 2)
| ^ | ^ help: add `;` here
LL | assert_eq!(3, 4) LL | assert_eq!(3, 4)
| --------- unexpected token | --------- unexpected token
|
help: add `;` here
|
LL | assert_eq!(1, 2);
| +
error: expected `;`, found `println` error: expected `;`, found `println`
--> $DIR/macros-no-semicolon.rs:3:21 --> $DIR/macros-no-semicolon.rs:3:21
| |
LL | assert_eq!(3, 4) LL | assert_eq!(3, 4)
| ^ | ^ help: add `;` here
LL | println!("hello"); LL | println!("hello");
| ------- unexpected token | ------- unexpected token
|
help: add `;` here
|
LL | assert_eq!(3, 4);
| +
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -19,15 +19,10 @@ error: expected `;`, found `#`
--> $DIR/raw-str-unbalanced.rs:10:28 --> $DIR/raw-str-unbalanced.rs:10:28
| |
LL | const A: &'static str = r"" LL | const A: &'static str = r""
| ^ | ^ help: add `;` here
... ...
LL | #[test] LL | #[test]
| - unexpected token | - unexpected token
|
help: add `;` here
|
LL | const A: &'static str = r"";
| +
error: too many `#` when terminating raw string error: too many `#` when terminating raw string
--> $DIR/raw-str-unbalanced.rs:16:28 --> $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 --> $DIR/recover-missing-semi-before-item.rs:6:16
| |
LL | let foo = 3 LL | let foo = 3
| ^ | ^ help: add `;` here
LL | struct Foo; LL | struct Foo;
| ------ unexpected token | ------ unexpected token
|
help: add `;` here
|
LL | let foo = 3;
| +
error: expected `;`, found `union` error: expected `;`, found `union`
--> $DIR/recover-missing-semi-before-item.rs:11:16 --> $DIR/recover-missing-semi-before-item.rs:11:16
| |
LL | let foo = 3 LL | let foo = 3
| ^ | ^ help: add `;` here
LL | union Foo { LL | union Foo {
| ----- unexpected token | ----- unexpected token
|
help: add `;` here
|
LL | let foo = 3;
| +
error: expected `;`, found keyword `enum` error: expected `;`, found keyword `enum`
--> $DIR/recover-missing-semi-before-item.rs:18:16 --> $DIR/recover-missing-semi-before-item.rs:18:16
| |
LL | let foo = 3 LL | let foo = 3
| ^ | ^ help: add `;` here
LL | enum Foo { LL | enum Foo {
| ---- unexpected token | ---- unexpected token
|
help: add `;` here
|
LL | let foo = 3;
| +
error: expected `;`, found keyword `fn` error: expected `;`, found keyword `fn`
--> $DIR/recover-missing-semi-before-item.rs:25:16 --> $DIR/recover-missing-semi-before-item.rs:25:16
| |
LL | let foo = 3 LL | let foo = 3
| ^ | ^ help: add `;` here
LL | fn foo() {} LL | fn foo() {}
| -- unexpected token | -- unexpected token
|
help: add `;` here
|
LL | let foo = 3;
| +
error: expected `;`, found keyword `extern` error: expected `;`, found keyword `extern`
--> $DIR/recover-missing-semi-before-item.rs:30:16 --> $DIR/recover-missing-semi-before-item.rs:30:16
| |
LL | let foo = 3 LL | let foo = 3
| ^ | ^ help: add `;` here
LL | extern fn foo() {} LL | extern fn foo() {}
| ------ unexpected token | ------ unexpected token
|
help: add `;` here
|
LL | let foo = 3;
| +
error: expected `;`, found keyword `impl` error: expected `;`, found keyword `impl`
--> $DIR/recover-missing-semi-before-item.rs:36:16 --> $DIR/recover-missing-semi-before-item.rs:36:16
| |
LL | let foo = 3 LL | let foo = 3
| ^ | ^ help: add `;` here
LL | impl Foo {} LL | impl Foo {}
| ---- unexpected token | ---- unexpected token
|
help: add `;` here
|
LL | let foo = 3;
| +
error: expected `;`, found keyword `pub` error: expected `;`, found keyword `pub`
--> $DIR/recover-missing-semi-before-item.rs:41:16 --> $DIR/recover-missing-semi-before-item.rs:41:16
| |
LL | let foo = 3 LL | let foo = 3
| ^ | ^ help: add `;` here
LL | pub use bar::Bar; LL | pub use bar::Bar;
| --- unexpected token | --- unexpected token
|
help: add `;` here
|
LL | let foo = 3;
| +
error: expected `;`, found keyword `mod` error: expected `;`, found keyword `mod`
--> $DIR/recover-missing-semi-before-item.rs:46:16 --> $DIR/recover-missing-semi-before-item.rs:46:16
| |
LL | let foo = 3 LL | let foo = 3
| ^ | ^ help: add `;` here
LL | mod foo {} LL | mod foo {}
| --- unexpected token | --- unexpected token
|
help: add `;` here
|
LL | let foo = 3;
| +
error: expected `;`, found keyword `type` error: expected `;`, found keyword `type`
--> $DIR/recover-missing-semi-before-item.rs:51:16 --> $DIR/recover-missing-semi-before-item.rs:51:16
| |
LL | let foo = 3 LL | let foo = 3
| ^ | ^ help: add `;` here
LL | type Foo = usize; LL | type Foo = usize;
| ---- unexpected token | ---- unexpected token
|
help: add `;` here
|
LL | let foo = 3;
| +
error: expected `;`, found keyword `fn` error: expected `;`, found keyword `fn`
--> $DIR/recover-missing-semi-before-item.rs:59:19 --> $DIR/recover-missing-semi-before-item.rs:59:19
| |
LL | const X: i32 = 123 LL | const X: i32 = 123
| ^ | ^ help: add `;` here
LL | LL |
LL | fn main() {} LL | fn main() {}
| -- unexpected token | -- unexpected token
|
help: add `;` here
|
LL | const X: i32 = 123;
| +
error: aborting due to 10 previous errors 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 --> $DIR/recover-missing-semi.rs:2:22
| |
LL | let _: usize = () LL | let _: usize = ()
| ^ | ^ help: add `;` here
... ...
LL | let _ = 3; LL | let _ = 3;
| --- unexpected token | --- unexpected token
|
help: add `;` here
|
LL | let _: usize = ();
| +
error: expected `;`, found keyword `return` error: expected `;`, found keyword `return`
--> $DIR/recover-missing-semi.rs:9:22 --> $DIR/recover-missing-semi.rs:9:22
| |
LL | let _: usize = () LL | let _: usize = ()
| ^ | ^ help: add `;` here
... ...
LL | return 3; LL | return 3;
| ------ unexpected token | ------ unexpected token
|
help: add `;` here
|
LL | let _: usize = ();
| +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/recover-missing-semi.rs:2:20 --> $DIR/recover-missing-semi.rs:2:20

View file

@ -2,27 +2,17 @@ error: expected `;`, found `}`
--> $DIR/missing-semicolon.rs:6:7 --> $DIR/missing-semicolon.rs:6:7
| |
LL | () LL | ()
| ^ | ^ help: add `;` here
LL | } LL | }
| - unexpected token | - unexpected token
|
help: add `;` here
|
LL | ();
| +
error: expected `;`, found `}` error: expected `;`, found `}`
--> $DIR/missing-semicolon.rs:32:7 --> $DIR/missing-semicolon.rs:32:7
| |
LL | () LL | ()
| ^ | ^ help: add `;` here
LL | } LL | }
| - unexpected token | - unexpected token
|
help: add `;` here
|
LL | ();
| +
error[E0618]: expected function, found `{integer}` error[E0618]: expected function, found `{integer}`
--> $DIR/missing-semicolon.rs:5:13 --> $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 --> $DIR/suggest-semicolon-for-fn-in-extern-block.rs:6:11
| |
LL | fn foo() LL | fn foo()
| ^ | ^ help: add `;` here
LL | } LL | }
| - unexpected token | - unexpected token
|
help: add `;` here
|
LL | fn foo();
| +
error: aborting due to 1 previous error error: aborting due to 1 previous error