Repository: rust-analyzer/rust-analyzer
Pull request #1383 (2019-06-07 11:51:00)

fix: never type with binding
Closes https://github.com/rust-analyzer/rust-analyzer/issues/1326
r? @matklad 


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 4fccddc5a4..562481b695 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -83,7 +83,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "bitflags"
-version = "1.1.0"
+version = "1.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -215,7 +215,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -238,7 +238,7 @@ name = "cloudabi"
 version = "0.0.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -446,7 +446,7 @@ name = "fsevent"
 version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -476,7 +476,7 @@ name = "fuchsia-zircon"
 version = "0.3.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -561,7 +561,7 @@ name = "inotify"
 version = "0.6.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -712,7 +712,7 @@ name = "lsp-types"
 version = "0.57.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -801,7 +801,7 @@ name = "notify"
 version = "4.0.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "filetime 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "fsevent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -973,7 +973,7 @@ version = "0.9.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1059,7 +1059,7 @@ dependencies = [
  "ra_syntax 0.1.0",
  "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "salsa 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "salsa 0.12.1 (git+https://github.com/matklad/salsa?branch=strong-panic-safety)",
  "test_utils 0.1.0",
 ]
 
@@ -1426,7 +1426,7 @@ version = "0.4.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1469,8 +1469,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "salsa"
-version = "0.12.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+version = "0.12.1"
+source = "git+https://github.com/matklad/salsa?branch=strong-panic-safety#fcc7058e9cbdec838a3d9e6721a0da2892fe4ce1"
 dependencies = [
  "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1478,14 +1478,14 @@ dependencies = [
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "salsa-macros 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "salsa-macros 0.12.1 (git+https://github.com/matklad/salsa?branch=strong-panic-safety)",
  "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "salsa-macros"
 version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+source = "git+https://github.com/matklad/salsa?branch=strong-panic-safety#fcc7058e9cbdec838a3d9e6721a0da2892fe4ce1"
 dependencies = [
  "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1993,7 +1993,7 @@ dependencies = [
 "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
 "checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80"
 "checksum bit-vec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb"
-"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
+"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
 "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
 "checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09"
 "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
@@ -2127,8 +2127,8 @@ dependencies = [
 "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
 "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
 "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f"
-"checksum salsa 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2208fabe493ad352dc4f544c482b39e9b9a2c1719d9aa4a0f5e828a61210956"
-"checksum salsa-macros 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7f1e25ca2b995bdf032946174929d62156ffd57abd7ff88dc6f9bdeb5ac0c59"
+"checksum salsa 0.12.1 (git+https://github.com/matklad/salsa?branch=strong-panic-safety)" = "<none>"
+"checksum salsa-macros 0.12.1 (git+https://github.com/matklad/salsa?branch=strong-panic-safety)" = "<none>"
 "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
 "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
 "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
diff --git a/Cargo.toml b/Cargo.toml
index c5155e8996..5106ea91d5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,3 +6,4 @@ incremental = true
 debug = true
 
 [patch.'crates-io']
+salsa = { git = "https://github.com/matklad/salsa", branch = "strong-panic-safety" }
\ No newline at end of file
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 99e32c4e82..795dccea15 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -137,12 +137,14 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
         m.complete(p, EXPR_STMT);
     }
 
-    // test let_stmt;
+    // test let_stmt
     // fn foo() {
     //     let a;
     //     let b: i32;
     //     let c = 92;
     //     let d: i32 = 92;
+    //     let e: !;
+    //     let _: ! = {};
     // }
     fn let_stmt(p: &mut Parser, m: Marker, with_semi: StmtWithSemi) {
         assert!(p.at(T![let]));
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs
index 8f654f04c0..8a2e253ac9 100644
--- a/crates/ra_parser/src/parser.rs
+++ b/crates/ra_parser/src/parser.rs
@@ -272,7 +272,7 @@ impl<'t> Parser<'t> {
             T![=] if jn1 && la2 == T![=] => Some((T![==], 2)),
             T![=] if jn1 && la2 == T![>] => Some((T![=>], 2)),
 
-            T![!] if la2 == T![=] => Some((T![!=], 2)),
+            T![!] if jn1 && la2 == T![=] => Some((T![!=], 2)),
             T![-] if la2 == T![>] => Some((T![->], 2)),
             _ => None,
         }


Test patch:
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0049_let_stmt;.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0130_let_stmt.rs
similarity index 70%
rename from crates/ra_syntax/tests/data/parser/inline/ok/0049_let_stmt;.rs
rename to crates/ra_syntax/tests/data/parser/inline/ok/0130_let_stmt.rs
index 0a9af907f5..86803fe08a 100644
--- a/crates/ra_syntax/tests/data/parser/inline/ok/0049_let_stmt;.rs
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0130_let_stmt.rs
@@ -3,4 +3,6 @@ fn foo() {
     let b: i32;
     let c = 92;
     let d: i32 = 92;
+    let e: !;
+    let _: ! = {};
 }
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0049_let_stmt;.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0130_let_stmt.txt
similarity index 63%
rename from crates/ra_syntax/tests/data/parser/inline/ok/0049_let_stmt;.txt
rename to crates/ra_syntax/tests/data/parser/inline/ok/0130_let_stmt.txt
index 1f7aa35873..82c1eb009b 100644
--- a/crates/ra_syntax/tests/data/parser/inline/ok/0049_let_stmt;.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0130_let_stmt.txt
@@ -1,5 +1,5 @@
-SOURCE_FILE@[0; 77)
-  FN_DEF@[0; 76)
+SOURCE_FILE@[0; 110)
+  FN_DEF@[0; 109)
     FN_KW@[0; 2) "fn"
     WHITESPACE@[2; 3) " "
     NAME@[3; 6)
@@ -8,7 +8,7 @@ SOURCE_FILE@[0; 77)
       L_PAREN@[6; 7) "("
       R_PAREN@[7; 8) ")"
     WHITESPACE@[8; 9) " "
-    BLOCK@[9; 76)
+    BLOCK@[9; 109)
       L_CURLY@[9; 10) "{"
       WHITESPACE@[10; 15) "\n    "
       LET_STMT@[15; 21)
@@ -66,6 +66,36 @@ SOURCE_FILE@[0; 77)
         LITERAL@[71; 73)
           INT_NUMBER@[71; 73) "92"
         SEMI@[73; 74) ";"
-      WHITESPACE@[74; 75) "\n"
-      R_CURLY@[75; 76) "}"
-  WHITESPACE@[76; 77) "\n"
+      WHITESPACE@[74; 79) "\n    "
+      LET_STMT@[79; 88)
+        LET_KW@[79; 82) "let"
+        WHITESPACE@[82; 83) " "
+        BIND_PAT@[83; 84)
+          NAME@[83; 84)
+            IDENT@[83; 84) "e"
+        COLON@[84; 85) ":"
+        WHITESPACE@[85; 86) " "
+        NEVER_TYPE@[86; 87)
+          EXCL@[86; 87) "!"
+        SEMI@[87; 88) ";"
+      WHITESPACE@[88; 93) "\n    "
+      LET_STMT@[93; 107)
+        LET_KW@[93; 96) "let"
+        WHITESPACE@[96; 97) " "
+        PLACEHOLDER_PAT@[97; 98)
+          UNDERSCORE@[97; 98) "_"
+        COLON@[98; 99) ":"
+        WHITESPACE@[99; 100) " "
+        NEVER_TYPE@[100; 101)
+          EXCL@[100; 101) "!"
+        WHITESPACE@[101; 102) " "
+        EQ@[102; 103) "="
+        WHITESPACE@[103; 104) " "
+        BLOCK_EXPR@[104; 106)
+          BLOCK@[104; 106)
+            L_CURLY@[104; 105) "{"
+            R_CURLY@[105; 106) "}"
+        SEMI@[106; 107) ";"
+      WHITESPACE@[107; 108) "\n"
+      R_CURLY@[108; 109) "}"
+  WHITESPACE@[109; 110) "\n"