mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
⬆️ rust-analyzer
This commit is contained in:
parent
22c8c9c401
commit
8231fee466
111 changed files with 5796 additions and 5130 deletions
|
@ -564,8 +564,10 @@ fn path_expr(p: &mut Parser<'_>, r: Restrictions) -> (CompletedMarker, BlockLike
|
|||
// test record_lit
|
||||
// fn foo() {
|
||||
// S {};
|
||||
// S { x };
|
||||
// S { x, y: 32, };
|
||||
// S { x, y: 32, ..Default::default() };
|
||||
// S { x: ::default() };
|
||||
// TupleStruct { 0: 1 };
|
||||
// }
|
||||
pub(crate) fn record_expr_field_list(p: &mut Parser<'_>) {
|
||||
|
@ -582,16 +584,26 @@ pub(crate) fn record_expr_field_list(p: &mut Parser<'_>) {
|
|||
|
||||
match p.current() {
|
||||
IDENT | INT_NUMBER => {
|
||||
// test_err record_literal_before_ellipsis_recovery
|
||||
// test_err record_literal_missing_ellipsis_recovery
|
||||
// fn main() {
|
||||
// S { field ..S::default() }
|
||||
// S { S::default() }
|
||||
// }
|
||||
if p.nth_at(1, T![:]) || p.nth_at(1, T![..]) {
|
||||
name_ref_or_index(p);
|
||||
p.expect(T![:]);
|
||||
if p.nth_at(1, T![::]) {
|
||||
m.abandon(p);
|
||||
p.expect(T![..]);
|
||||
expr(p);
|
||||
} else {
|
||||
// test_err record_literal_before_ellipsis_recovery
|
||||
// fn main() {
|
||||
// S { field ..S::default() }
|
||||
// }
|
||||
if p.nth_at(1, T![:]) || p.nth_at(1, T![..]) {
|
||||
name_ref_or_index(p);
|
||||
p.expect(T![:]);
|
||||
}
|
||||
expr(p);
|
||||
m.complete(p, RECORD_EXPR_FIELD);
|
||||
}
|
||||
expr(p);
|
||||
m.complete(p, RECORD_EXPR_FIELD);
|
||||
}
|
||||
T![.] if p.at(T![..]) => {
|
||||
m.abandon(p);
|
||||
|
|
|
@ -75,6 +75,16 @@ fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
|
|||
// Some(1..) => ()
|
||||
// }
|
||||
//
|
||||
// match () {
|
||||
// S { a: 0 } => (),
|
||||
// S { a: 1.. } => (),
|
||||
// }
|
||||
//
|
||||
// match () {
|
||||
// [0] => (),
|
||||
// [1..] => (),
|
||||
// }
|
||||
//
|
||||
// match (10 as u8, 5 as u8) {
|
||||
// (0, _) => (),
|
||||
// (1.., _) => ()
|
||||
|
@ -88,11 +98,27 @@ fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
|
|||
let m = lhs.precede(p);
|
||||
p.bump(range_op);
|
||||
|
||||
// `0 .. =>` or `let 0 .. =` or `Some(0 .. )`
|
||||
// ^ ^ ^
|
||||
if p.at(T![=]) | p.at(T![')']) | p.at(T![,]) {
|
||||
// testing if we're at one of the following positions:
|
||||
// `0 .. =>`
|
||||
// ^
|
||||
// `let 0 .. =`
|
||||
// ^
|
||||
// `let 0..: _ =`
|
||||
// ^
|
||||
// (1.., _)
|
||||
// ^
|
||||
// `Some(0 .. )`
|
||||
// ^
|
||||
// `S { t: 0.. }`
|
||||
// ^
|
||||
// `[0..]`
|
||||
// ^
|
||||
if matches!(p.current(), T![=] | T![,] | T![:] | T![')'] | T!['}'] | T![']']) {
|
||||
// test half_open_range_pat
|
||||
// fn f() { let 0 .. = 1u32; }
|
||||
// fn f() {
|
||||
// let 0 .. = 1u32;
|
||||
// let 0..: _ = 1u32;
|
||||
// }
|
||||
} else {
|
||||
atom_pat(p, recovery_set);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue