@@ -127,10 +127,10 @@ crate enum RibKind<'a> {
127
127
/// We passed through a `macro_rules!` statement
128
128
MacroDefinition ( DefId ) ,
129
129
130
- /// All bindings in this rib are type parameters that can't be used
131
- /// from the default of a type parameter because they're not declared
132
- /// before said type parameter. Also see the `visit_generics` override.
133
- ForwardTyParamBanRibKind ,
130
+ /// All bindings in this rib are generic parameters that can't be used
131
+ /// from the default of a generic parameter because they're not declared
132
+ /// before said generic parameter. Also see the `visit_generics` override.
133
+ ForwardGenericParamBanRibKind ,
134
134
135
135
/// We are inside of the type of a const parameter. Can't refer to any
136
136
/// parameters.
@@ -149,7 +149,7 @@ impl RibKind<'_> {
149
149
| ModuleRibKind ( _)
150
150
| MacroDefinition ( _)
151
151
| ConstParamTyRibKind => false ,
152
- AssocItemRibKind | ItemRibKind ( _) | ForwardTyParamBanRibKind => true ,
152
+ AssocItemRibKind | ItemRibKind ( _) | ForwardGenericParamBanRibKind => true ,
153
153
}
154
154
}
155
155
}
@@ -535,15 +535,16 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
535
535
// provide previous type parameters as they're built. We
536
536
// put all the parameters on the ban list and then remove
537
537
// them one by one as they are processed and become available.
538
- let mut default_ban_rib = Rib :: new ( ForwardTyParamBanRibKind ) ;
538
+ let mut default_ban_rib = Rib :: new ( ForwardGenericParamBanRibKind ) ;
539
539
let mut found_default = false ;
540
540
default_ban_rib. bindings . extend ( generics. params . iter ( ) . filter_map (
541
541
|param| match param. kind {
542
- GenericParamKind :: Const { .. } | GenericParamKind :: Lifetime { .. } => None ,
543
- GenericParamKind :: Type { ref default, .. } => {
544
- found_default |= default . is_some ( ) ;
545
- found_default . then_some ( ( Ident :: with_dummy_span ( param. ident . name ) , Res :: Err ) )
542
+ GenericParamKind :: Type { default : Some ( _ ) , .. }
543
+ | GenericParamKind :: Const { default : Some ( _ ) , .. } => {
544
+ found_default = true ;
545
+ Some ( ( Ident :: with_dummy_span ( param. ident . name ) , Res :: Err ) )
546
546
}
547
+ _ => None ,
547
548
} ,
548
549
) ) ;
549
550
@@ -571,8 +572,8 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
571
572
572
573
if let Some ( ref ty) = default {
573
574
self . ribs [ TypeNS ] . push ( default_ban_rib) ;
574
- self . with_rib ( ValueNS , ForwardTyParamBanRibKind , |this| {
575
- // HACK: We use an empty `ForwardTyParamBanRibKind ` here which
575
+ self . with_rib ( ValueNS , ForwardGenericParamBanRibKind , |this| {
576
+ // HACK: We use an empty `ForwardGenericParamBanRibKind ` here which
576
577
// is only used to forbid the use of const parameters inside of
577
578
// type defaults.
578
579
//
@@ -587,6 +588,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
587
588
default_ban_rib. bindings . remove ( & Ident :: with_dummy_span ( param. ident . name ) ) ;
588
589
}
589
590
GenericParamKind :: Const { ref ty, kw_span : _, default : _ } => {
591
+ // FIXME(const_generic_defaults): handle `default`
590
592
for bound in & param. bounds {
591
593
self . visit_param_bound ( bound) ;
592
594
}
@@ -595,7 +597,6 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
595
597
self . visit_ty ( ty) ;
596
598
self . ribs [ TypeNS ] . pop ( ) . unwrap ( ) ;
597
599
self . ribs [ ValueNS ] . pop ( ) . unwrap ( ) ;
598
- // FIXME(const_generics:default) do something with default here?
599
600
}
600
601
}
601
602
}
@@ -845,7 +846,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
845
846
| ItemRibKind ( ..)
846
847
| ConstantItemRibKind ( _)
847
848
| ModuleRibKind ( ..)
848
- | ForwardTyParamBanRibKind
849
+ | ForwardGenericParamBanRibKind
849
850
| ConstParamTyRibKind => {
850
851
return false ;
851
852
}
0 commit comments