mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 01:38:13 +00:00
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 <csmoe@msn.com>
This commit is contained in:
commit
2a6b363b44
4 changed files with 42 additions and 8 deletions
|
@ -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]));
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -3,4 +3,6 @@ fn foo() {
|
|||
let b: i32;
|
||||
let c = 92;
|
||||
let d: i32 = 92;
|
||||
let e: !;
|
||||
let _: ! = {};
|
||||
}
|
|
@ -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"
|
Loading…
Reference in a new issue