@@ -1715,9 +1715,6 @@ impl<'a> Parser<'a> {
17151715
17161716/// The parsing configuration used to parse a parameter list (see `parse_fn_params`).
17171717pub ( super ) struct ParamCfg {
1718- /// Is `self` is *semantically* allowed as the first parameter?
1719- /// This is only used for diagnostics.
1720- pub in_assoc_item : bool ,
17211718 /// `is_name_required` decides if, per-parameter,
17221719 /// the parameter must have a pattern or just a type.
17231720 pub is_name_required : fn ( & token:: Token ) -> bool ,
@@ -1733,7 +1730,7 @@ impl<'a> Parser<'a> {
17331730 attrs : Vec < Attribute > ,
17341731 header : FnHeader ,
17351732 ) -> PResult < ' a , Option < P < Item > > > {
1736- let cfg = ParamCfg { in_assoc_item : false , is_name_required : |_| true } ;
1733+ let cfg = ParamCfg { is_name_required : |_| true } ;
17371734 let ( ident, decl, generics) = self . parse_fn_sig ( & cfg) ?;
17381735 let ( inner_attrs, body) = self . parse_inner_attrs_and_block ( ) ?;
17391736 let kind = ItemKind :: Fn ( FnSig { decl, header } , generics, body) ;
@@ -1748,7 +1745,7 @@ impl<'a> Parser<'a> {
17481745 attrs : Vec < Attribute > ,
17491746 extern_sp : Span ,
17501747 ) -> PResult < ' a , P < ForeignItem > > {
1751- let cfg = ParamCfg { in_assoc_item : false , is_name_required : |_| true } ;
1748+ let cfg = ParamCfg { is_name_required : |_| true } ;
17521749 self . expect_keyword ( kw:: Fn ) ?;
17531750 let ( ident, decl, generics) = self . parse_fn_sig ( & cfg) ?;
17541751 let span = lo. to ( self . token . span ) ;
@@ -1763,9 +1760,8 @@ impl<'a> Parser<'a> {
17631760 attrs : & mut Vec < Attribute > ,
17641761 is_name_required : fn ( & token:: Token ) -> bool ,
17651762 ) -> PResult < ' a , ( Ident , AssocItemKind , Generics ) > {
1766- let cfg = ParamCfg { in_assoc_item : true , is_name_required } ;
17671763 let header = self . parse_fn_front_matter ( ) ?;
1768- let ( ident, decl, generics) = self . parse_fn_sig ( & cfg ) ?;
1764+ let ( ident, decl, generics) = self . parse_fn_sig ( & ParamCfg { is_name_required } ) ?;
17691765 let sig = FnSig { header, decl } ;
17701766 let body = self . parse_assoc_fn_body ( at_end, attrs) ?;
17711767 Ok ( ( ident, AssocItemKind :: Fn ( sig, body) , generics) )
@@ -1893,11 +1889,7 @@ impl<'a> Parser<'a> {
18931889 // Possibly parse `self`. Recover if we parsed it and it wasn't allowed here.
18941890 if let Some ( mut param) = self . parse_self_param ( ) ? {
18951891 param. attrs = attrs. into ( ) ;
1896- return if first_param {
1897- Ok ( param)
1898- } else {
1899- self . recover_bad_self_param ( param, cfg. in_assoc_item )
1900- } ;
1892+ return if first_param { Ok ( param) } else { self . recover_bad_self_param ( param) } ;
19011893 }
19021894
19031895 let is_name_required = match self . token . kind {
@@ -1909,13 +1901,9 @@ impl<'a> Parser<'a> {
19091901
19101902 let pat = self . parse_fn_param_pat ( ) ?;
19111903 if let Err ( mut err) = self . expect ( & token:: Colon ) {
1912- return if let Some ( ident) = self . parameter_without_type (
1913- & mut err,
1914- pat,
1915- is_name_required,
1916- first_param && cfg. in_assoc_item ,
1917- cfg. in_assoc_item ,
1918- ) {
1904+ return if let Some ( ident) =
1905+ self . parameter_without_type ( & mut err, pat, is_name_required, first_param)
1906+ {
19191907 err. emit ( ) ;
19201908 Ok ( dummy_arg ( ident) )
19211909 } else {
0 commit comments