summaryrefslogtreecommitdiffstats
path: root/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests')
-rw-r--r--src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe.rs37
-rw-r--r--src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs21
-rw-r--r--src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/proc_macros.rs7
3 files changed, 49 insertions, 16 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe.rs b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe.rs
index 2d5f2a692..7a3e8c3b0 100644
--- a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe.rs
+++ b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe.rs
@@ -97,6 +97,41 @@ fn#19 main#20(#21)#21 {#22
"##]],
);
}
+#[test]
+fn float_field_acces_macro_input() {
+ check(
+ r#"
+macro_rules! foo {
+ ($expr:expr) => {
+ fn foo() {
+ $expr;
+ }
+ };
+}
+foo!(x .0.1);
+foo!(x .2. 3);
+foo!(x .4 .5);
+"#,
+ expect![[r#"
+macro_rules! foo {
+ ($expr:expr) => {
+ fn foo() {
+ $expr;
+ }
+ };
+}
+fn foo() {
+ (x.0.1);
+}
+fn foo() {
+ (x.2.3);
+}
+fn foo() {
+ (x.4.5);
+}
+"#]],
+ );
+}
#[test]
fn mbe_smoke_test() {
@@ -1441,7 +1476,7 @@ macro_rules! m {
/* parse error: expected identifier */
/* parse error: expected SEMICOLON */
/* parse error: expected SEMICOLON */
-/* parse error: expected expression */
+/* parse error: expected expression, item or let statement */
fn f() {
K::(C("0"));
}
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs
index d2505e7ca..8358a46f0 100644
--- a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs
+++ b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs
@@ -830,8 +830,7 @@ macro_rules! rgb_color {
/* parse error: expected COMMA */
/* parse error: expected R_ANGLE */
/* parse error: expected SEMICOLON */
-/* parse error: expected SEMICOLON */
-/* parse error: expected expression */
+/* parse error: expected expression, item or let statement */
pub fn new() {
let _ = 0as u32<<(8+8);
}
@@ -848,21 +847,21 @@ pub fn new() {
// BLOCK_EXPR@10..31
// STMT_LIST@10..31
// L_CURLY@10..11 "{"
-// LET_STMT@11..27
+// LET_STMT@11..28
// LET_KW@11..14 "let"
// WILDCARD_PAT@14..15
// UNDERSCORE@14..15 "_"
// EQ@15..16 "="
-// CAST_EXPR@16..27
+// CAST_EXPR@16..28
// LITERAL@16..17
// INT_NUMBER@16..17 "0"
// AS_KW@17..19 "as"
-// PATH_TYPE@19..27
-// PATH@19..27
-// PATH_SEGMENT@19..27
+// PATH_TYPE@19..28
+// PATH@19..28
+// PATH_SEGMENT@19..28
// NAME_REF@19..22
// IDENT@19..22 "u32"
-// GENERIC_ARG_LIST@22..27
+// GENERIC_ARG_LIST@22..28
// L_ANGLE@22..23 "<"
// TYPE_ARG@23..27
// DYN_TRAIT_TYPE@23..27
@@ -877,9 +876,9 @@ pub fn new() {
// ERROR@25..26
// INT_NUMBER@25..26 "8"
// PLUS@26..27 "+"
-// EXPR_STMT@27..28
-// LITERAL@27..28
-// INT_NUMBER@27..28 "8"
+// CONST_ARG@27..28
+// LITERAL@27..28
+// INT_NUMBER@27..28 "8"
// ERROR@28..29
// R_PAREN@28..29 ")"
// SEMICOLON@29..30 ";"
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/proc_macros.rs b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
index 118c14ed8..822bdcc12 100644
--- a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
+++ b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
@@ -104,7 +104,7 @@ macro_rules! id {
$($t)*
};
}
-id /*+errors*/! {
+id! {
#[proc_macros::identity]
impl Foo for WrapBj {
async fn foo(&self) {
@@ -113,18 +113,17 @@ id /*+errors*/! {
}
}
"#,
- expect![[r##"
+ expect![[r#"
macro_rules! id {
($($t:tt)*) => {
$($t)*
};
}
-/* parse error: expected SEMICOLON */
#[proc_macros::identity] impl Foo for WrapBj {
async fn foo(&self ) {
self .0.id().await ;
}
}
-"##]],
+"#]],
);
}