@@ -115,9 +115,6 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
115
115
self . check_variances_for_type_defn ( item, ast_generics) ;
116
116
}
117
117
ast:: ItemTrait ( _, _, _, ref items) => {
118
- let trait_predicates =
119
- ccx. tcx . lookup_predicates ( local_def ( item. id ) ) ;
120
- reject_non_type_param_bounds ( ccx. tcx , item. span , & trait_predicates) ;
121
118
if ccx. tcx . trait_has_default_impl ( local_def ( item. id ) ) {
122
119
if !items. is_empty ( ) {
123
120
wfcheck:: error_380 ( ccx, item. span ) ;
@@ -135,7 +132,6 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
135
132
let item_def_id = local_def ( item. id ) ;
136
133
let type_scheme = ccx. tcx . lookup_item_type ( item_def_id) ;
137
134
let type_predicates = ccx. tcx . lookup_predicates ( item_def_id) ;
138
- reject_non_type_param_bounds ( ccx. tcx , item. span , & type_predicates) ;
139
135
let param_env = ccx. tcx . construct_parameter_environment ( item. span ,
140
136
& type_scheme. generics ,
141
137
& type_predicates,
@@ -367,44 +363,6 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
367
363
}
368
364
}
369
365
370
- // Reject any predicates that do not involve a type parameter.
371
- fn reject_non_type_param_bounds < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
372
- span : Span ,
373
- predicates : & ty:: GenericPredicates < ' tcx > ) {
374
- for predicate in & predicates. predicates {
375
- match predicate {
376
- & ty:: Predicate :: Trait ( ty:: Binder ( ref tr) ) => {
377
- let found_param = tr. input_types ( ) . iter ( )
378
- . flat_map ( |ty| ty. walk ( ) )
379
- . any ( is_ty_param) ;
380
- if !found_param { report_bound_error ( tcx, span, tr. self_ty ( ) ) }
381
- }
382
- & ty:: Predicate :: TypeOutlives ( ty:: Binder ( ty:: OutlivesPredicate ( ty, _) ) ) => {
383
- let found_param = ty. walk ( ) . any ( |t| is_ty_param ( t) ) ;
384
- if !found_param { report_bound_error ( tcx, span, ty) }
385
- }
386
- _ => { }
387
- } ;
388
- }
389
-
390
- fn report_bound_error < ' t > ( tcx : & ty:: ctxt < ' t > ,
391
- span : Span ,
392
- bounded_ty : ty:: Ty < ' t > ) {
393
- span_err ! ( tcx. sess, span, E0193 ,
394
- "cannot bound type `{}`, where clause \
395
- bounds may only be attached to types involving \
396
- type parameters",
397
- bounded_ty)
398
- }
399
-
400
- fn is_ty_param ( ty : ty:: Ty ) -> bool {
401
- match & ty. sty {
402
- & ty:: TyParam ( _) => true ,
403
- _ => false
404
- }
405
- }
406
- }
407
-
408
366
fn reject_shadowing_type_parameters < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
409
367
span : Span ,
410
368
generics : & ty:: Generics < ' tcx > ) {
@@ -445,10 +403,6 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
445
403
if let ast:: MethodTraitItem ( _, None ) = trait_item. node {
446
404
match self . tcx ( ) . impl_or_trait_item ( local_def ( trait_item. id ) ) {
447
405
ty:: ImplOrTraitItem :: MethodTraitItem ( ty_method) => {
448
- reject_non_type_param_bounds (
449
- self . tcx ( ) ,
450
- trait_item. span ,
451
- & ty_method. predicates ) ;
452
406
reject_shadowing_type_parameters (
453
407
self . tcx ( ) ,
454
408
trait_item. span ,
0 commit comments