@@ -399,37 +399,25 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
399
399
// For more examples see tests `defaults-well-formedness.rs` and `type-check-defaults.rs`.
400
400
//
401
401
// First we build the defaulted substitution.
402
- let mut defaulted_params = Vec :: new ( ) ;
403
402
let substs = ty:: subst:: Substs :: for_item ( fcx. tcx , def_id, |def, _| {
404
403
// All regions are identity.
405
404
fcx. tcx . mk_region ( ty:: ReEarlyBound ( def. to_early_bound_region_data ( ) ) )
406
405
} , |def, _| {
407
406
if !is_our_default ( def) {
408
- // Identity substitution.
409
- fcx. tcx . mk_param_from_def ( def )
407
+ // We don't want to use non-defaulted params in a substitution, mark as err .
408
+ fcx. tcx . types . err
410
409
} else {
411
410
// Substitute with default.
412
- defaulted_params. push ( def. index ) ;
413
411
fcx. tcx . type_of ( def. def_id )
414
412
}
415
413
} ) ;
416
- let defaulted_params = & defaulted_params;
417
414
// Now we build the substituted predicates.
418
415
for & pred in predicates. predicates . iter ( ) {
419
- struct HasNonDefaulted < ' a > { defaulted_params : & ' a Vec < u32 > }
420
- impl < ' tcx , ' a > ty:: fold:: TypeVisitor < ' tcx > for HasNonDefaulted < ' a > {
421
- fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> bool {
422
- match t. sty {
423
- ty:: TyParam ( p) => !self . defaulted_params . contains ( & p. idx ) ,
424
- _ => t. super_visit_with ( self )
425
- }
426
- }
427
- }
416
+ let substituted_pred = pred. subst ( fcx. tcx , substs) ;
428
417
// If there is a non-defaulted param in the predicate, don't check it.
429
- if pred . visit_with ( & mut HasNonDefaulted { defaulted_params } ) {
418
+ if substituted_pred . references_error ( ) {
430
419
continue ;
431
420
}
432
- let substituted_pred = pred. subst ( fcx. tcx , substs) ;
433
421
// In trait defs, don't check `Self: Sized` when `Self` is the default.
434
422
if let ty:: Predicate :: Trait ( trait_pred) = substituted_pred {
435
423
// `skip_binder()` is ok, we're only inspecting for `has_self_ty()`.
0 commit comments