@@ -449,7 +449,9 @@ fn postfix_dot_expr<const FLOAT_RECOVERY: bool>(
449
449
let nth1 = if FLOAT_RECOVERY { 0 } else { 1 } ;
450
450
let nth2 = if FLOAT_RECOVERY { 1 } else { 2 } ;
451
451
452
- if p. nth ( nth1) == IDENT && ( p. nth ( nth2) == T ! [ '(' ] || p. nth_at ( nth2, T ! [ :: ] ) ) {
452
+ if PATH_NAME_REF_KINDS . contains ( p. nth ( nth1) )
453
+ && ( p. nth ( nth2) == T ! [ '(' ] || p. nth_at ( nth2, T ! [ :: ] ) )
454
+ {
453
455
return Ok ( method_call_expr :: < FLOAT_RECOVERY > ( p, lhs) ) ;
454
456
}
455
457
@@ -510,21 +512,26 @@ fn index_expr(p: &mut Parser<'_>, lhs: CompletedMarker) -> CompletedMarker {
510
512
// y.bar::<T>(1, 2,);
511
513
// x.0.0.call();
512
514
// x.0. call();
515
+ // x.0()
513
516
// }
514
517
fn method_call_expr < const FLOAT_RECOVERY : bool > (
515
518
p : & mut Parser < ' _ > ,
516
519
lhs : CompletedMarker ,
517
520
) -> CompletedMarker {
518
521
if FLOAT_RECOVERY {
519
- assert ! ( p. nth ( 0 ) == IDENT && ( p. nth( 1 ) == T ![ '(' ] || p. nth_at( 1 , T ![ :: ] ) ) ) ;
522
+ assert ! ( p. at_ts ( PATH_NAME_REF_KINDS ) && ( p. nth( 1 ) == T ![ '(' ] || p. nth_at( 1 , T ![ :: ] ) ) ) ;
520
523
} else {
521
- assert ! ( p. at( T ![ . ] ) && p. nth( 1 ) == IDENT && ( p. nth( 2 ) == T ![ '(' ] || p. nth_at( 2 , T ![ :: ] ) ) ) ;
524
+ assert ! (
525
+ p. at( T ![ . ] )
526
+ && PATH_NAME_REF_KINDS . contains( p. nth( 1 ) )
527
+ && ( p. nth( 2 ) == T ![ '(' ] || p. nth_at( 2 , T ![ :: ] ) )
528
+ ) ;
522
529
}
523
530
let m = lhs. precede ( p) ;
524
531
if !FLOAT_RECOVERY {
525
532
p. bump ( T ! [ . ] ) ;
526
533
}
527
- name_ref ( p) ;
534
+ name_ref_mod_path ( p) ;
528
535
generic_args:: opt_generic_arg_list_expr ( p) ;
529
536
if p. at ( T ! [ '(' ] ) {
530
537
arg_list ( p) ;
@@ -543,6 +550,8 @@ fn method_call_expr<const FLOAT_RECOVERY: bool>(
543
550
544
551
// test field_expr
545
552
// fn foo() {
553
+ // x.self;
554
+ // x.Self;
546
555
// x.foo;
547
556
// x.0.bar;
548
557
// x.0.1;
@@ -560,8 +569,8 @@ fn field_expr<const FLOAT_RECOVERY: bool>(
560
569
if !FLOAT_RECOVERY {
561
570
p. bump ( T ! [ . ] ) ;
562
571
}
563
- if p. at ( IDENT ) || p . at ( INT_NUMBER ) {
564
- name_ref_or_index ( p) ;
572
+ if p. at_ts ( PATH_NAME_REF_OR_INDEX_KINDS ) {
573
+ name_ref_mod_path_or_index ( p) ;
565
574
} else if p. at ( FLOAT_NUMBER ) {
566
575
return match p. split_float ( m) {
567
576
( true , m) => {
@@ -679,34 +688,37 @@ pub(crate) fn record_expr_field_list(p: &mut Parser<'_>) {
679
688
IDENT | INT_NUMBER if p. nth_at ( 1 , T ! [ :: ] ) => {
680
689
// test_err record_literal_missing_ellipsis_recovery
681
690
// fn main() {
682
- // S { S::default() }
691
+ // S { S::default() };
692
+ // S { 0::default() };
683
693
// }
684
694
m. abandon ( p) ;
685
695
p. expect ( T ! [ ..] ) ;
686
696
expr ( p) ;
687
697
}
698
+ IDENT | INT_NUMBER if p. nth_at ( 1 , T ! [ ..] ) => {
699
+ // test_err record_literal_before_ellipsis_recovery
700
+ // fn main() {
701
+ // S { field ..S::default() }
702
+ // S { 0 ..S::default() }
703
+ // }
704
+ name_ref_or_index ( p) ;
705
+ p. error ( "expected `:`" ) ;
706
+ m. complete ( p, RECORD_EXPR_FIELD ) ;
707
+ }
688
708
IDENT | INT_NUMBER => {
689
- if p. nth_at ( 1 , T ! [ ..] ) {
690
- // test_err record_literal_before_ellipsis_recovery
691
- // fn main() {
692
- // S { field ..S::default() }
693
- // }
709
+ // test_err record_literal_field_eq_recovery
710
+ // fn main() {
711
+ // S { field = foo }
712
+ // S { 0 = foo }
713
+ // }
714
+ if p. nth_at ( 1 , T ! [ : ] ) {
694
715
name_ref_or_index ( p) ;
695
- p. error ( "expected `:`" ) ;
696
- } else {
697
- // test_err record_literal_field_eq_recovery
698
- // fn main() {
699
- // S { field = foo }
700
- // }
701
- if p. nth_at ( 1 , T ! [ : ] ) {
702
- name_ref_or_index ( p) ;
703
- p. bump ( T ! [ : ] ) ;
704
- } else if p. nth_at ( 1 , T ! [ =] ) {
705
- name_ref_or_index ( p) ;
706
- p. err_and_bump ( "expected `:`" ) ;
707
- }
708
- expr ( p) ;
716
+ p. bump ( T ! [ : ] ) ;
717
+ } else if p. nth_at ( 1 , T ! [ =] ) {
718
+ name_ref_or_index ( p) ;
719
+ p. err_and_bump ( "expected `:`" ) ;
709
720
}
721
+ expr ( p) ;
710
722
m. complete ( p, RECORD_EXPR_FIELD ) ;
711
723
}
712
724
T ! [ . ] if p. at ( T ! [ ..] ) => {
0 commit comments