about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonas Schievink <jonas.schievink@ferrous-systems.com>2022-05-13 15:27:17 +0200
committerJonas Schievink <jonas.schievink@ferrous-systems.com>2022-05-13 15:54:46 +0200
commit0831f3123bc0cf12d35c775a4072fb92d9b03549 (patch)
tree3e036a1656248b2eba7601d0293986b5c4c97b1c
parent9bd11459baf12c77c32549916174631e4817c107 (diff)
downloadrust-0831f3123bc0cf12d35c775a4072fb92d9b03549.tar.gz
rust-0831f3123bc0cf12d35c775a4072fb92d9b03549.zip
Fix tests
-rw-r--r--crates/hir-def/src/macro_expansion_tests/mbe.rs8
-rw-r--r--crates/hir-def/src/macro_expansion_tests/proc_macros.rs3
-rw-r--r--crates/ide-completion/src/context.rs2
3 files changed, 8 insertions, 5 deletions
diff --git a/crates/hir-def/src/macro_expansion_tests/mbe.rs b/crates/hir-def/src/macro_expansion_tests/mbe.rs
index 8e019204832..befef6547cb 100644
--- a/crates/hir-def/src/macro_expansion_tests/mbe.rs
+++ b/crates/hir-def/src/macro_expansion_tests/mbe.rs
@@ -48,6 +48,8 @@ struct#10 MyTraitMap2#32 {#13
 
 #[test]
 fn token_mapping_floats() {
+    // Regression test for https://github.com/rust-lang/rust-analyzer/issues/12216
+    // (and related issues)
     check(
         r#"
 // +tokenids
@@ -87,9 +89,9 @@ macro_rules! f {#0
 // }
 fn#19 main#20(#21)#21 {#22
     1#23;#24
-    1#26.0;
-    let x#31 =#22 1;
-}
+    1.0#25;#26
+    let#27 x#28 =#29 1#30;#31
+}#22
 
 
 "##]],
diff --git a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
index a4448329209..72c44a0fbcb 100644
--- a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
+++ b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
@@ -104,7 +104,7 @@ macro_rules! id {
         $($t)*
     };
 }
-id! {
+id /*+errors*/! {
     #[proc_macros::identity]
     impl Foo for WrapBj {
         async fn foo(&self) {
@@ -119,6 +119,7 @@ macro_rules! id {
         $($t)*
     };
 }
+/* parse error: expected SEMICOLON */
 #[proc_macros::identity] impl Foo for WrapBj {
     async fn foo(&self ) {
         self .0.id().await ;
diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs
index 4a058ac2619..fbf3278ad1f 100644
--- a/crates/ide-completion/src/context.rs
+++ b/crates/ide-completion/src/context.rs
@@ -1062,7 +1062,7 @@ impl<'a> CompletionContext<'a> {
                     let receiver_is_ambiguous_float_literal = match &receiver {
                         Some(ast::Expr::Literal(l)) => matches! {
                             l.kind(),
-                            ast::LiteralKind::FloatNumber { .. } if l.syntax().last_token().map_or(false, |it| it.kind() == T![.])
+                            ast::LiteralKind::FloatNumber { .. } if l.syntax().last_token().map_or(false, |it| it.text().ends_with('.'))
                         },
                         _ => false,
                     };