@@ -127,10 +127,10 @@ crate enum RibKind<'a> {
127127 /// We passed through a `macro_rules!` statement
128128 MacroDefinition ( DefId ) ,
129129
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 ,
134134
135135 /// We are inside of the type of a const parameter. Can't refer to any
136136 /// parameters.
@@ -149,7 +149,7 @@ impl RibKind<'_> {
149149 | ModuleRibKind ( _)
150150 | MacroDefinition ( _)
151151 | ConstParamTyRibKind => false ,
152- AssocItemRibKind | ItemRibKind ( _) | ForwardTyParamBanRibKind => true ,
152+ AssocItemRibKind | ItemRibKind ( _) | ForwardGenericParamBanRibKind => true ,
153153 }
154154 }
155155}
@@ -535,15 +535,16 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
535535 // provide previous type parameters as they're built. We
536536 // put all the parameters on the ban list and then remove
537537 // 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 ) ;
539539 let mut found_default = false ;
540540 default_ban_rib. bindings . extend ( generics. params . iter ( ) . filter_map (
541541 |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 ) )
546546 }
547+ _ => None ,
547548 } ,
548549 ) ) ;
549550
@@ -571,8 +572,8 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
571572
572573 if let Some ( ref ty) = default {
573574 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
576577 // is only used to forbid the use of const parameters inside of
577578 // type defaults.
578579 //
@@ -587,6 +588,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
587588 default_ban_rib. bindings . remove ( & Ident :: with_dummy_span ( param. ident . name ) ) ;
588589 }
589590 GenericParamKind :: Const { ref ty, kw_span : _, default : _ } => {
591+ // FIXME(const_generic_defaults): handle `default`
590592 for bound in & param. bounds {
591593 self . visit_param_bound ( bound) ;
592594 }
@@ -595,7 +597,6 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
595597 self . visit_ty ( ty) ;
596598 self . ribs [ TypeNS ] . pop ( ) . unwrap ( ) ;
597599 self . ribs [ ValueNS ] . pop ( ) . unwrap ( ) ;
598- // FIXME(const_generics:default) do something with default here?
599600 }
600601 }
601602 }
@@ -845,7 +846,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
845846 | ItemRibKind ( ..)
846847 | ConstantItemRibKind ( _)
847848 | ModuleRibKind ( ..)
848- | ForwardTyParamBanRibKind
849+ | ForwardGenericParamBanRibKind
849850 | ConstParamTyRibKind => {
850851 return false ;
851852 }
0 commit comments