@@ -4,7 +4,7 @@ use crate::errors::{
4
4
self , DynAfterMut , ExpectedFnPathFoundFnKeyword , ExpectedMutOrConstInRawPointerType ,
5
5
FnPointerCannotBeAsync , FnPointerCannotBeConst , FnPtrWithGenerics , FnPtrWithGenericsSugg ,
6
6
InvalidDynKeyword , LifetimeAfterMut , NeedPlusAfterTraitObjectLifetime , NestedCVariadicType ,
7
- ReturnTypesUseThinArrow ,
7
+ ReturnTypesUseThinArrow , UnexpectedDefaultParameterInBinder ,
8
8
} ;
9
9
use crate :: { maybe_recover_from_interpolated_ty_qpath, maybe_whole} ;
10
10
@@ -14,8 +14,8 @@ use rustc_ast::token::{self, Delimiter, Token, TokenKind};
14
14
use rustc_ast:: util:: case:: Case ;
15
15
use rustc_ast:: {
16
16
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 ,
19
19
} ;
20
20
use rustc_errors:: { Applicability , PResult } ;
21
21
use rustc_span:: symbol:: { kw, sym, Ident } ;
@@ -1033,6 +1033,16 @@ impl<'a> Parser<'a> {
1033
1033
if self . eat_keyword ( kw:: For ) {
1034
1034
self . expect_lt ( ) ?;
1035
1035
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 ( ) ;
1036
1046
self . expect_gt ( ) ?;
1037
1047
// We rely on AST validation to rule out invalid cases: There must not be type
1038
1048
// parameters, and the lifetime parameters must not have bounds.
0 commit comments