@@ -4,7 +4,7 @@ use crate::errors::{
44 self , DynAfterMut , ExpectedFnPathFoundFnKeyword , ExpectedMutOrConstInRawPointerType ,
55 FnPointerCannotBeAsync , FnPointerCannotBeConst , FnPtrWithGenerics , FnPtrWithGenericsSugg ,
66 InvalidDynKeyword , LifetimeAfterMut , NeedPlusAfterTraitObjectLifetime , NestedCVariadicType ,
7- ReturnTypesUseThinArrow ,
7+ ReturnTypesUseThinArrow , UnexpectedDefaultParameterInBinder ,
88} ;
99use crate :: { maybe_recover_from_interpolated_ty_qpath, maybe_whole} ;
1010
@@ -14,8 +14,8 @@ use rustc_ast::token::{self, Delimiter, Token, TokenKind};
1414use rustc_ast:: util:: case:: Case ;
1515use rustc_ast:: {
1616 self as ast, BareFnTy , BoundPolarity , FnRetTy , GenericBound , GenericBounds , GenericParam ,
17- Generics , Lifetime , MacCall , MutTy , Mutability , PolyTraitRef , TraitBoundModifier ,
18- TraitObjectSyntax , Ty , TyKind ,
17+ GenericParamKind , Generics , Lifetime , MacCall , MutTy , Mutability , PolyTraitRef ,
18+ TraitBoundModifier , TraitObjectSyntax , Ty , TyKind ,
1919} ;
2020use rustc_errors:: { Applicability , PResult } ;
2121use rustc_span:: symbol:: { kw, sym, Ident } ;
@@ -1033,6 +1033,16 @@ impl<'a> Parser<'a> {
10331033 if self . eat_keyword ( kw:: For ) {
10341034 self . expect_lt ( ) ?;
10351035 let params = self . parse_generic_params ( ) ?;
1036+ let params = params
1037+ . into_iter ( )
1038+ . map ( |param| match param. kind {
1039+ GenericParamKind :: Type { ref default } if let Some ( ty) = default => {
1040+ self . sess . emit_err ( UnexpectedDefaultParameterInBinder { span : ty. span } ) ;
1041+ GenericParam { kind : GenericParamKind :: Type { default : None } , ..param }
1042+ }
1043+ _ => param,
1044+ } )
1045+ . collect ( ) ;
10361046 self . expect_gt ( ) ?;
10371047 // We rely on AST validation to rule out invalid cases: There must not be type
10381048 // parameters, and the lifetime parameters must not have bounds.
0 commit comments