@@ -1715,9 +1715,6 @@ impl<'a> Parser<'a> {
1715
1715
1716
1716
/// The parsing configuration used to parse a parameter list (see `parse_fn_params`).
1717
1717
pub ( 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 ,
1721
1718
/// `is_name_required` decides if, per-parameter,
1722
1719
/// the parameter must have a pattern or just a type.
1723
1720
pub is_name_required : fn ( & token:: Token ) -> bool ,
@@ -1733,7 +1730,7 @@ impl<'a> Parser<'a> {
1733
1730
attrs : Vec < Attribute > ,
1734
1731
header : FnHeader ,
1735
1732
) -> 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 } ;
1737
1734
let ( ident, decl, generics) = self . parse_fn_sig ( & cfg) ?;
1738
1735
let ( inner_attrs, body) = self . parse_inner_attrs_and_block ( ) ?;
1739
1736
let kind = ItemKind :: Fn ( FnSig { decl, header } , generics, body) ;
@@ -1748,7 +1745,7 @@ impl<'a> Parser<'a> {
1748
1745
attrs : Vec < Attribute > ,
1749
1746
extern_sp : Span ,
1750
1747
) -> PResult < ' a , P < ForeignItem > > {
1751
- let cfg = ParamCfg { in_assoc_item : false , is_name_required : |_| true } ;
1748
+ let cfg = ParamCfg { is_name_required : |_| true } ;
1752
1749
self . expect_keyword ( kw:: Fn ) ?;
1753
1750
let ( ident, decl, generics) = self . parse_fn_sig ( & cfg) ?;
1754
1751
let span = lo. to ( self . token . span ) ;
@@ -1763,9 +1760,8 @@ impl<'a> Parser<'a> {
1763
1760
attrs : & mut Vec < Attribute > ,
1764
1761
is_name_required : fn ( & token:: Token ) -> bool ,
1765
1762
) -> PResult < ' a , ( Ident , AssocItemKind , Generics ) > {
1766
- let cfg = ParamCfg { in_assoc_item : true , is_name_required } ;
1767
1763
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 } ) ?;
1769
1765
let sig = FnSig { header, decl } ;
1770
1766
let body = self . parse_assoc_fn_body ( at_end, attrs) ?;
1771
1767
Ok ( ( ident, AssocItemKind :: Fn ( sig, body) , generics) )
@@ -1893,11 +1889,7 @@ impl<'a> Parser<'a> {
1893
1889
// Possibly parse `self`. Recover if we parsed it and it wasn't allowed here.
1894
1890
if let Some ( mut param) = self . parse_self_param ( ) ? {
1895
1891
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) } ;
1901
1893
}
1902
1894
1903
1895
let is_name_required = match self . token . kind {
@@ -1909,13 +1901,9 @@ impl<'a> Parser<'a> {
1909
1901
1910
1902
let pat = self . parse_fn_param_pat ( ) ?;
1911
1903
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
+ {
1919
1907
err. emit ( ) ;
1920
1908
Ok ( dummy_arg ( ident) )
1921
1909
} else {
0 commit comments