@@ -449,7 +449,9 @@ fn postfix_dot_expr<const FLOAT_RECOVERY: bool>(
449449 let nth1 = if FLOAT_RECOVERY { 0 } else { 1 } ;
450450 let nth2 = if FLOAT_RECOVERY { 1 } else { 2 } ;
451451
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+ {
453455 return Ok ( method_call_expr :: < FLOAT_RECOVERY > ( p, lhs) ) ;
454456 }
455457
@@ -510,21 +512,26 @@ fn index_expr(p: &mut Parser<'_>, lhs: CompletedMarker) -> CompletedMarker {
510512// y.bar::<T>(1, 2,);
511513// x.0.0.call();
512514// x.0. call();
515+ // x.0()
513516// }
514517fn method_call_expr < const FLOAT_RECOVERY : bool > (
515518 p : & mut Parser < ' _ > ,
516519 lhs : CompletedMarker ,
517520) -> CompletedMarker {
518521 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 ![ :: ] ) ) ) ;
520523 } 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+ ) ;
522529 }
523530 let m = lhs. precede ( p) ;
524531 if !FLOAT_RECOVERY {
525532 p. bump ( T ! [ . ] ) ;
526533 }
527- name_ref ( p) ;
534+ name_ref_mod_path ( p) ;
528535 generic_args:: opt_generic_arg_list_expr ( p) ;
529536 if p. at ( T ! [ '(' ] ) {
530537 arg_list ( p) ;
@@ -543,6 +550,8 @@ fn method_call_expr<const FLOAT_RECOVERY: bool>(
543550
544551// test field_expr
545552// fn foo() {
553+ // x.self;
554+ // x.Self;
546555// x.foo;
547556// x.0.bar;
548557// x.0.1;
@@ -560,8 +569,8 @@ fn field_expr<const FLOAT_RECOVERY: bool>(
560569 if !FLOAT_RECOVERY {
561570 p. bump ( T ! [ . ] ) ;
562571 }
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) ;
565574 } else if p. at ( FLOAT_NUMBER ) {
566575 return match p. split_float ( m) {
567576 ( true , m) => {
@@ -679,34 +688,37 @@ pub(crate) fn record_expr_field_list(p: &mut Parser<'_>) {
679688 IDENT | INT_NUMBER if p. nth_at ( 1 , T ! [ :: ] ) => {
680689 // test_err record_literal_missing_ellipsis_recovery
681690 // fn main() {
682- // S { S::default() }
691+ // S { S::default() };
692+ // S { 0::default() };
683693 // }
684694 m. abandon ( p) ;
685695 p. expect ( T ! [ ..] ) ;
686696 expr ( p) ;
687697 }
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+ }
688708 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 ! [ : ] ) {
694715 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 `:`" ) ;
709720 }
721+ expr ( p) ;
710722 m. complete ( p, RECORD_EXPR_FIELD ) ;
711723 }
712724 T ! [ . ] if p. at ( T ! [ ..] ) => {
0 commit comments