summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2023-05-03 11:46:34 +0800
committeryukang <moorekang@gmail.com>2023-05-08 10:56:20 +0800
commit0bb43c63c33bf29e7a24e696f619be8e55e62f37 (patch)
tree35e583a3194d2e531e3d49a8b9daf112ae813926 /tests
parentad6b20bf5225c65aab30169c9a173719f5bdfc04 (diff)
downloadrust-0bb43c63c33bf29e7a24e696f619be8e55e62f37.tar.gz
Suggest let for possible binding with ty
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/suggestions/type-ascription-instead-of-let.fixed11
-rw-r--r--tests/ui/suggestions/type-ascription-instead-of-let.rs4
-rw-r--r--tests/ui/suggestions/type-ascription-instead-of-let.stderr7
-rw-r--r--tests/ui/type/missing-let-in-binding-2.fixed5
-rw-r--r--tests/ui/type/missing-let-in-binding-2.rs5
-rw-r--r--tests/ui/type/missing-let-in-binding-2.stderr13
6 files changed, 43 insertions, 2 deletions
diff --git a/tests/ui/suggestions/type-ascription-instead-of-let.fixed b/tests/ui/suggestions/type-ascription-instead-of-let.fixed
new file mode 100644
index 00000000000..e3d03b6f22a
--- /dev/null
+++ b/tests/ui/suggestions/type-ascription-instead-of-let.fixed
@@ -0,0 +1,11 @@
+// run-rustfix
+
+fn fun(x: i32) -> i32 { x }
+
+fn main() {
+ let _closure_annotated = |value: i32| -> i32 {
+ let temp: i32 = fun(5i32);
+ //~^ ERROR expected identifier, found `:`
+ temp + value + 1
+ };
+}
diff --git a/tests/ui/suggestions/type-ascription-instead-of-let.rs b/tests/ui/suggestions/type-ascription-instead-of-let.rs
index 5ad60243298..6e1c86f9671 100644
--- a/tests/ui/suggestions/type-ascription-instead-of-let.rs
+++ b/tests/ui/suggestions/type-ascription-instead-of-let.rs
@@ -1,7 +1,9 @@
+// run-rustfix
+
fn fun(x: i32) -> i32 { x }
fn main() {
- let closure_annotated = |value: i32| -> i32 {
+ let _closure_annotated = |value: i32| -> i32 {
temp: i32 = fun(5i32);
//~^ ERROR expected identifier, found `:`
temp + value + 1
diff --git a/tests/ui/suggestions/type-ascription-instead-of-let.stderr b/tests/ui/suggestions/type-ascription-instead-of-let.stderr
index fb697b0ccfd..065b1f4d353 100644
--- a/tests/ui/suggestions/type-ascription-instead-of-let.stderr
+++ b/tests/ui/suggestions/type-ascription-instead-of-let.stderr
@@ -1,8 +1,13 @@
error: expected identifier, found `:`
- --> $DIR/type-ascription-instead-of-let.rs:5:13
+ --> $DIR/type-ascription-instead-of-let.rs:7:13
|
LL | temp: i32 = fun(5i32);
| ^ expected identifier
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let temp: i32 = fun(5i32);
+ | +++
error: aborting due to previous error
diff --git a/tests/ui/type/missing-let-in-binding-2.fixed b/tests/ui/type/missing-let-in-binding-2.fixed
new file mode 100644
index 00000000000..d64013c8c83
--- /dev/null
+++ b/tests/ui/type/missing-let-in-binding-2.fixed
@@ -0,0 +1,5 @@
+// run-rustfix
+
+fn main() {
+ let _v: Vec<i32> = vec![1, 2, 3]; //~ ERROR expected identifier, found `:`
+}
diff --git a/tests/ui/type/missing-let-in-binding-2.rs b/tests/ui/type/missing-let-in-binding-2.rs
new file mode 100644
index 00000000000..f95f7bef215
--- /dev/null
+++ b/tests/ui/type/missing-let-in-binding-2.rs
@@ -0,0 +1,5 @@
+// run-rustfix
+
+fn main() {
+ _v: Vec<i32> = vec![1, 2, 3]; //~ ERROR expected identifier, found `:`
+}
diff --git a/tests/ui/type/missing-let-in-binding-2.stderr b/tests/ui/type/missing-let-in-binding-2.stderr
new file mode 100644
index 00000000000..2e10125943e
--- /dev/null
+++ b/tests/ui/type/missing-let-in-binding-2.stderr
@@ -0,0 +1,13 @@
+error: expected identifier, found `:`
+ --> $DIR/missing-let-in-binding-2.rs:4:7
+ |
+LL | _v: Vec<i32> = vec![1, 2, 3];
+ | ^ expected identifier
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let _v: Vec<i32> = vec![1, 2, 3];
+ | +++
+
+error: aborting due to previous error
+