@@ -71,10 +71,6 @@ struct AstValidator<'a> {
71
71
/// or `Foo::Bar<impl Trait>`
72
72
is_impl_trait_banned : bool ,
73
73
74
- /// Used to ban associated type bounds (i.e., `Type<AssocType: Bounds>`) in
75
- /// certain positions.
76
- is_assoc_ty_bound_banned : bool ,
77
-
78
74
/// See [ForbiddenLetReason]
79
75
forbidden_let_reason : Option < ForbiddenLetReason > ,
80
76
@@ -180,30 +176,12 @@ impl<'a> AstValidator<'a> {
180
176
}
181
177
}
182
178
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
-
189
179
fn with_impl_trait ( & mut self , outer : Option < Span > , f : impl FnOnce ( & mut Self ) ) {
190
180
let old = mem:: replace ( & mut self . outer_impl_trait , outer) ;
191
181
f ( self ) ;
192
182
self . outer_impl_trait = old;
193
183
}
194
184
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
-
207
185
// Mirrors `visit::walk_ty`, but tracks relevant state.
208
186
fn walk_ty ( & mut self , t : & ' a Ty ) {
209
187
match & t. kind {
@@ -1248,7 +1226,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1248
1226
// are allowed to contain nested `impl Trait`.
1249
1227
AngleBracketedArg :: Constraint ( constraint) => {
1250
1228
self . with_impl_trait ( None , |this| {
1251
- this. visit_assoc_constraint_from_generic_args ( constraint) ;
1229
+ this. visit_assoc_constraint ( constraint) ;
1252
1230
} ) ;
1253
1231
}
1254
1232
}
@@ -1373,14 +1351,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1373
1351
visit:: walk_param_bound ( self , bound)
1374
1352
}
1375
1353
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
-
1384
1354
fn visit_fn ( & mut self , fk : FnKind < ' a > , span : Span , id : NodeId ) {
1385
1355
// Only associated `fn`s can have `self` parameters.
1386
1356
let self_semantic = match fk. ctxt ( ) {
@@ -1709,7 +1679,6 @@ pub fn check_crate(session: &Session, krate: &Crate, lints: &mut LintBuffer) ->
1709
1679
outer_impl_trait : None ,
1710
1680
disallow_tilde_const : None ,
1711
1681
is_impl_trait_banned : false ,
1712
- is_assoc_ty_bound_banned : false ,
1713
1682
forbidden_let_reason : Some ( ForbiddenLetReason :: GenericForbidden ) ,
1714
1683
lint_buffer : lints,
1715
1684
} ;
0 commit comments