diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-07 14:41:31 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-07 14:41:31 +0100 |
commit | 2a6b363b44e335af5f26ac503461ef15cca82ace (patch) | |
tree | a818d95421f791dcd58e8d42e34dfe0cd6dac305 | |
parent | b81d9a4d452abd49553f78c478f486632be8f92e (diff) | |
parent | 205a8278a9da4bc1289449b916468e972fb624fc (diff) |
Merge #1383
1383: fix: never type with binding r=matklad a=csmoe
Closes https://github.com/rust-analyzer/rust-analyzer/issues/1326
r? @matklad
Co-authored-by: csmoe <[email protected]>
-rw-r--r-- | crates/ra_parser/src/grammar/expressions.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/parser.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0130_let_stmt.rs (renamed from crates/ra_syntax/tests/data/parser/inline/ok/0049_let_stmt;.rs) | 2 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0130_let_stmt.txt (renamed from crates/ra_syntax/tests/data/parser/inline/ok/0049_let_stmt;.txt) | 42 |
4 files changed, 42 insertions, 8 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 99e32c4e8..795dccea1 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) { | |||
137 | m.complete(p, EXPR_STMT); | 137 | m.complete(p, EXPR_STMT); |
138 | } | 138 | } |
139 | 139 | ||
140 | // test let_stmt; | 140 | // test let_stmt |
141 | // fn foo() { | 141 | // fn foo() { |
142 | // let a; | 142 | // let a; |
143 | // let b: i32; | 143 | // let b: i32; |
144 | // let c = 92; | 144 | // let c = 92; |
145 | // let d: i32 = 92; | 145 | // let d: i32 = 92; |
146 | // let e: !; | ||
147 | // let _: ! = {}; | ||
146 | // } | 148 | // } |
147 | fn let_stmt(p: &mut Parser, m: Marker, with_semi: StmtWithSemi) { | 149 | fn let_stmt(p: &mut Parser, m: Marker, with_semi: StmtWithSemi) { |
148 | assert!(p.at(T![let])); | 150 | assert!(p.at(T![let])); |
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index 8f654f04c..8a2e253ac 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs | |||
@@ -272,7 +272,7 @@ impl<'t> Parser<'t> { | |||
272 | T![=] if jn1 && la2 == T![=] => Some((T![==], 2)), | 272 | T![=] if jn1 && la2 == T![=] => Some((T![==], 2)), |
273 | T![=] if jn1 && la2 == T![>] => Some((T![=>], 2)), | 273 | T![=] if jn1 && la2 == T![>] => Some((T![=>], 2)), |
274 | 274 | ||
275 | T![!] if la2 == T![=] => Some((T![!=], 2)), | 275 | T![!] if jn1 && la2 == T![=] => Some((T![!=], 2)), |
276 | T![-] if la2 == T![>] => Some((T![->], 2)), | 276 | T![-] if la2 == T![>] => Some((T![->], 2)), |
277 | _ => None, | 277 | _ => None, |
278 | } | 278 | } |
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 index 0a9af907f..86803fe08 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() { | |||
3 | let b: i32; | 3 | let b: i32; |
4 | let c = 92; | 4 | let c = 92; |
5 | let d: i32 = 92; | 5 | let d: i32 = 92; |
6 | let e: !; | ||
7 | let _: ! = {}; | ||
6 | } | 8 | } |
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 index 1f7aa3587..82c1eb009 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 @@ | |||
1 | SOURCE_FILE@[0; 77) | 1 | SOURCE_FILE@[0; 110) |
2 | FN_DEF@[0; 76) | 2 | FN_DEF@[0; 109) |
3 | FN_KW@[0; 2) "fn" | 3 | FN_KW@[0; 2) "fn" |
4 | WHITESPACE@[2; 3) " " | 4 | WHITESPACE@[2; 3) " " |
5 | NAME@[3; 6) | 5 | NAME@[3; 6) |
@@ -8,7 +8,7 @@ SOURCE_FILE@[0; 77) | |||
8 | L_PAREN@[6; 7) "(" | 8 | L_PAREN@[6; 7) "(" |
9 | R_PAREN@[7; 8) ")" | 9 | R_PAREN@[7; 8) ")" |
10 | WHITESPACE@[8; 9) " " | 10 | WHITESPACE@[8; 9) " " |
11 | BLOCK@[9; 76) | 11 | BLOCK@[9; 109) |
12 | L_CURLY@[9; 10) "{" | 12 | L_CURLY@[9; 10) "{" |
13 | WHITESPACE@[10; 15) "\n " | 13 | WHITESPACE@[10; 15) "\n " |
14 | LET_STMT@[15; 21) | 14 | LET_STMT@[15; 21) |
@@ -66,6 +66,36 @@ SOURCE_FILE@[0; 77) | |||
66 | LITERAL@[71; 73) | 66 | LITERAL@[71; 73) |
67 | INT_NUMBER@[71; 73) "92" | 67 | INT_NUMBER@[71; 73) "92" |
68 | SEMI@[73; 74) ";" | 68 | SEMI@[73; 74) ";" |
69 | WHITESPACE@[74; 75) "\n" | 69 | WHITESPACE@[74; 79) "\n " |
70 | R_CURLY@[75; 76) "}" | 70 | LET_STMT@[79; 88) |
71 | WHITESPACE@[76; 77) "\n" | 71 | LET_KW@[79; 82) "let" |
72 | WHITESPACE@[82; 83) " " | ||
73 | BIND_PAT@[83; 84) | ||
74 | NAME@[83; 84) | ||
75 | IDENT@[83; 84) "e" | ||
76 | COLON@[84; 85) ":" | ||
77 | WHITESPACE@[85; 86) " " | ||
78 | NEVER_TYPE@[86; 87) | ||
79 | EXCL@[86; 87) "!" | ||
80 | SEMI@[87; 88) ";" | ||
81 | WHITESPACE@[88; 93) "\n " | ||
82 | LET_STMT@[93; 107) | ||
83 | LET_KW@[93; 96) "let" | ||
84 | WHITESPACE@[96; 97) " " | ||
85 | PLACEHOLDER_PAT@[97; 98) | ||
86 | UNDERSCORE@[97; 98) "_" | ||
87 | COLON@[98; 99) ":" | ||
88 | WHITESPACE@[99; 100) " " | ||
89 | NEVER_TYPE@[100; 101) | ||
90 | EXCL@[100; 101) "!" | ||
91 | WHITESPACE@[101; 102) " " | ||
92 | EQ@[102; 103) "=" | ||
93 | WHITESPACE@[103; 104) " " | ||
94 | BLOCK_EXPR@[104; 106) | ||
95 | BLOCK@[104; 106) | ||
96 | L_CURLY@[104; 105) "{" | ||
97 | R_CURLY@[105; 106) "}" | ||
98 | SEMI@[106; 107) ";" | ||
99 | WHITESPACE@[107; 108) "\n" | ||
100 | R_CURLY@[108; 109) "}" | ||
101 | WHITESPACE@[109; 110) "\n" | ||