@@ -71,10 +71,6 @@ struct AstValidator<'a> {
7171 /// or `Foo::Bar<impl Trait>`
7272 is_impl_trait_banned : bool ,
7373
74- /// Used to ban associated type bounds (i.e., `Type<AssocType: Bounds>`) in
75- /// certain positions.
76- is_assoc_ty_bound_banned : bool ,
77-
7874 /// See [ForbiddenLetReason]
7975 forbidden_let_reason : Option < ForbiddenLetReason > ,
8076
@@ -180,30 +176,12 @@ impl<'a> AstValidator<'a> {
180176 }
181177 }
182178
183- fn with_banned_assoc_ty_bound ( & mut self , f : impl FnOnce ( & mut Self ) ) {
184- let old = mem:: replace ( & mut self . is_assoc_ty_bound_banned , true ) ;
185- f ( self ) ;
186- self . is_assoc_ty_bound_banned = old;
187- }
188-
189179 fn with_impl_trait ( & mut self , outer : Option < Span > , f : impl FnOnce ( & mut Self ) ) {
190180 let old = mem:: replace ( & mut self . outer_impl_trait , outer) ;
191181 f ( self ) ;
192182 self . outer_impl_trait = old;
193183 }
194184
195- fn visit_assoc_constraint_from_generic_args ( & mut self , constraint : & ' a AssocConstraint ) {
196- match constraint. kind {
197- AssocConstraintKind :: Equality { .. } => { }
198- AssocConstraintKind :: Bound { .. } => {
199- if self . is_assoc_ty_bound_banned {
200- self . session . emit_err ( ForbiddenAssocConstraint { span : constraint. span } ) ;
201- }
202- }
203- }
204- self . visit_assoc_constraint ( constraint) ;
205- }
206-
207185 // Mirrors `visit::walk_ty`, but tracks relevant state.
208186 fn walk_ty ( & mut self , t : & ' a Ty ) {
209187 match & t. kind {
@@ -1248,7 +1226,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12481226 // are allowed to contain nested `impl Trait`.
12491227 AngleBracketedArg :: Constraint ( constraint) => {
12501228 self . with_impl_trait ( None , |this| {
1251- this. visit_assoc_constraint_from_generic_args ( constraint) ;
1229+ this. visit_assoc_constraint ( constraint) ;
12521230 } ) ;
12531231 }
12541232 }
@@ -1373,14 +1351,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13731351 visit:: walk_param_bound ( self , bound)
13741352 }
13751353
1376- fn visit_variant_data ( & mut self , s : & ' a VariantData ) {
1377- self . with_banned_assoc_ty_bound ( |this| visit:: walk_struct_def ( this, s) )
1378- }
1379-
1380- fn visit_enum_def ( & mut self , enum_definition : & ' a EnumDef ) {
1381- self . with_banned_assoc_ty_bound ( |this| visit:: walk_enum_def ( this, enum_definition) )
1382- }
1383-
13841354 fn visit_fn ( & mut self , fk : FnKind < ' a > , span : Span , id : NodeId ) {
13851355 // Only associated `fn`s can have `self` parameters.
13861356 let self_semantic = match fk. ctxt ( ) {
@@ -1709,7 +1679,6 @@ pub fn check_crate(session: &Session, krate: &Crate, lints: &mut LintBuffer) ->
17091679 outer_impl_trait : None ,
17101680 disallow_tilde_const : None ,
17111681 is_impl_trait_banned : false ,
1712- is_assoc_ty_bound_banned : false ,
17131682 forbidden_let_reason : Some ( ForbiddenLetReason :: GenericForbidden ) ,
17141683 lint_buffer : lints,
17151684 } ;
0 commit comments