@@ -287,6 +287,25 @@ impl<'a> PostExpansionVisitor<'a> {
287287 err. emit ( ) ;
288288 }
289289 }
290+
291+ fn check_gat ( & self , generics : & ast:: Generics , span : Span ) {
292+ if !generics. params . is_empty ( ) {
293+ gate_feature_post ! (
294+ & self ,
295+ generic_associated_types,
296+ span,
297+ "generic associated types are unstable"
298+ ) ;
299+ }
300+ if !generics. where_clause . predicates . is_empty ( ) {
301+ gate_feature_post ! (
302+ & self ,
303+ generic_associated_types,
304+ span,
305+ "where clauses on associated types are unstable"
306+ ) ;
307+ }
308+ }
290309}
291310
292311impl < ' a > Visitor < ' a > for PostExpansionVisitor < ' a > {
@@ -566,14 +585,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
566585 gate_feature_post ! ( & self , associated_type_defaults, ti. span,
567586 "associated type defaults are unstable" ) ;
568587 }
569- if !ti. generics . params . is_empty ( ) {
570- gate_feature_post ! ( & self , generic_associated_types, ti. span,
571- "generic associated types are unstable" ) ;
572- }
573- if !ti. generics . where_clause . predicates . is_empty ( ) {
574- gate_feature_post ! ( & self , generic_associated_types, ti. span,
575- "where clauses on associated types are unstable" ) ;
576- }
588+ self . check_gat ( & ti. generics , ti. span ) ;
577589 }
578590 _ => { }
579591 }
@@ -603,14 +615,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
603615 ) ;
604616 }
605617 ast:: ImplItemKind :: TyAlias ( _) => {
606- if !ii. generics . params . is_empty ( ) {
607- gate_feature_post ! ( & self , generic_associated_types, ii. span,
608- "generic associated types are unstable" ) ;
609- }
610- if !ii. generics . where_clause . predicates . is_empty ( ) {
611- gate_feature_post ! ( & self , generic_associated_types, ii. span,
612- "where clauses on associated types are unstable" ) ;
613- }
618+ self . check_gat ( & ii. generics , ii. span ) ;
614619 }
615620 _ => { }
616621 }
0 commit comments