@@ -4642,25 +4642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4642
4642
// First, store the "user substs" for later.
4643
4643
self . write_user_type_annotation_from_substs ( hir_id, def_id, substs, user_self_ty) ;
4644
4644
4645
- // Add all the obligations that are required, substituting and
4646
- // normalized appropriately.
4647
- let ( bounds, spans) = self . instantiate_bounds ( span, def_id, & substs) ;
4648
-
4649
- for ( i, mut obligation) in traits:: predicates_for_generics (
4650
- traits:: ObligationCause :: new (
4651
- span,
4652
- self . body_id ,
4653
- traits:: ItemObligation ( def_id) ,
4654
- ) ,
4655
- self . param_env ,
4656
- & bounds,
4657
- ) . into_iter ( ) . enumerate ( ) {
4658
- // This makes the error point at the bound, but we want to point at the argument
4659
- if let Some ( span) = spans. get ( i) {
4660
- obligation. cause . code = traits:: BindingObligation ( def_id, * span) ;
4661
- }
4662
- self . register_predicate ( obligation) ;
4663
- }
4645
+ self . add_required_obligations ( span, def_id, & substs) ;
4664
4646
4665
4647
// Substitute the values for the type parameters into the type of
4666
4648
// the referenced item.
@@ -4697,6 +4679,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4697
4679
( ty_substituted, res)
4698
4680
}
4699
4681
4682
+ /// Add all the obligations that are required, substituting and normalized appropriately.
4683
+ fn add_required_obligations ( & self , span : Span , def_id : DefId , substs : & SubstsRef < ' tcx > ) {
4684
+ let ( bounds, spans) = self . instantiate_bounds ( span, def_id, & substs) ;
4685
+
4686
+ for ( i, mut obligation) in traits:: predicates_for_generics (
4687
+ traits:: ObligationCause :: new (
4688
+ span,
4689
+ self . body_id ,
4690
+ traits:: ItemObligation ( def_id) ,
4691
+ ) ,
4692
+ self . param_env ,
4693
+ & bounds,
4694
+ ) . into_iter ( ) . enumerate ( ) {
4695
+ // This makes the error point at the bound, but we want to point at the argument
4696
+ if let Some ( span) = spans. get ( i) {
4697
+ obligation. cause . code = traits:: BindingObligation ( def_id, * span) ;
4698
+ }
4699
+ self . register_predicate ( obligation) ;
4700
+ }
4701
+ }
4702
+
4700
4703
fn check_rustc_args_require_const ( & self ,
4701
4704
def_id : DefId ,
4702
4705
hir_id : hir:: HirId ,
0 commit comments