Unnamed repository; edit this file 'description' to name the repository.
intenral: more local tests for statics
Aleksey Kladov 2021-09-18
parent 1feb8e8 · commit 3474e3b
-rw-r--r--crates/parser/src/grammar/items/consts.rs13
-rw-r--r--crates/syntax/test_data/parser/inline/err/0013_anonymous_static.rast (renamed from crates/syntax/test_data/parser/inline/err/0013_static_underscore.rast)0
-rw-r--r--crates/syntax/test_data/parser/inline/err/0013_anonymous_static.rs (renamed from crates/syntax/test_data/parser/inline/err/0013_static_underscore.rs)0
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0172_const_item.rast20
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0172_const_item.rs1
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0173_anonymous_const.rast19
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0173_anonymous_const.rs1
-rw-r--r--crates/syntax/test_data/parser/ok/0024_const_item.rast39
-rw-r--r--crates/syntax/test_data/parser/ok/0024_const_item.rs2
9 files changed, 50 insertions, 45 deletions
diff --git a/crates/parser/src/grammar/items/consts.rs b/crates/parser/src/grammar/items/consts.rs
index 52379411e4..93ba7d05fe 100644
--- a/crates/parser/src/grammar/items/consts.rs
+++ b/crates/parser/src/grammar/items/consts.rs
@@ -1,5 +1,7 @@
use super::*;
+// test const_item
+// const C: u32 = 92;
pub(super) fn konst(p: &mut Parser, m: Marker) {
p.bump(T![const]);
const_or_static(p, m, true)
@@ -13,14 +15,15 @@ pub(super) fn static_(p: &mut Parser, m: Marker) {
fn const_or_static(p: &mut Parser, m: Marker, is_const: bool) {
p.eat(T![mut]);
- // Allow `_` in place of an identifier in a `const`.
- let is_const_underscore = is_const && p.eat(T![_]);
- if !is_const_underscore {
+ if is_const && p.eat(T![_]) {
+ // test anonymous_const
+ // const _: u32 = 0;
+ } else {
+ // test_err anonymous_static
+ // static _: i32 = 5;
name(p);
}
- // test_err static_underscore
- // static _: i32 = 5;
if p.at(T![:]) {
types::ascription(p);
} else {
diff --git a/crates/syntax/test_data/parser/inline/err/0013_static_underscore.rast b/crates/syntax/test_data/parser/inline/err/0013_anonymous_static.rast
index 8d761b9074..8d761b9074 100644
--- a/crates/syntax/test_data/parser/inline/err/0013_static_underscore.rast
+++ b/crates/syntax/test_data/parser/inline/err/0013_anonymous_static.rast
diff --git a/crates/syntax/test_data/parser/inline/err/0013_static_underscore.rs b/crates/syntax/test_data/parser/inline/err/0013_anonymous_static.rs
index df8cecb432..df8cecb432 100644
--- a/crates/syntax/test_data/parser/inline/err/0013_static_underscore.rs
+++ b/crates/syntax/test_data/parser/inline/err/0013_anonymous_static.rs
diff --git a/crates/syntax/test_data/parser/inline/ok/0172_const_item.rast b/crates/syntax/test_data/parser/inline/ok/0172_const_item.rast
new file mode 100644
index 0000000000..8a61d5e566
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0172_const_item.rast
@@ -0,0 +1,20 @@
diff --git a/crates/syntax/test_data/parser/inline/ok/0172_const_item.rs b/crates/syntax/test_data/parser/inline/ok/0172_const_item.rs
new file mode 100644
index 0000000000..6d5f5be65d
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0172_const_item.rs
@@ -0,0 +1 @@
+const C: u32 = 92;
diff --git a/crates/syntax/test_data/parser/inline/ok/0173_anonymous_const.rast b/crates/syntax/test_data/parser/inline/ok/0173_anonymous_const.rast
new file mode 100644
index 0000000000..68ce503c39
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0173_anonymous_const.rast
@@ -0,0 +1,19 @@
diff --git a/crates/syntax/test_data/parser/inline/ok/0173_anonymous_const.rs b/crates/syntax/test_data/parser/inline/ok/0173_anonymous_const.rs
new file mode 100644
index 0000000000..c1d5cdfc62
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0173_anonymous_const.rs
@@ -0,0 +1 @@
+const _: u32 = 0;
diff --git a/crates/syntax/test_data/parser/ok/0024_const_item.rast b/crates/syntax/test_data/parser/ok/0024_const_item.rast
index b89ed6f98e..6b234b0b24 100644
--- a/crates/syntax/test_data/parser/ok/0024_const_item.rast
+++ b/crates/syntax/test_data/parser/ok/0024_const_item.rast
@@ -1,38 +1 @@
diff --git a/crates/syntax/test_data/parser/ok/0024_const_item.rs b/crates/syntax/test_data/parser/ok/0024_const_item.rs
index 1f2ffa0da3..e69de29bb2 100644
--- a/crates/syntax/test_data/parser/ok/0024_const_item.rs
+++ b/crates/syntax/test_data/parser/ok/0024_const_item.rs
@@ -1,2 +0,0 @@
-const _: u32 = 0;
-const FOO: u32 = 92;