@@ -4611,25 +4611,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4611
4611
// First, store the "user substs" for later.
4612
4612
self . write_user_type_annotation_from_substs ( hir_id, def_id, substs, user_self_ty) ;
4613
4613
4614
- // Add all the obligations that are required, substituting and
4615
- // normalized appropriately.
4616
- let ( bounds, spans) = self . instantiate_bounds ( span, def_id, & substs) ;
4617
-
4618
- for ( i, mut obligation) in traits:: predicates_for_generics (
4619
- traits:: ObligationCause :: new (
4620
- span,
4621
- self . body_id ,
4622
- traits:: ItemObligation ( def_id) ,
4623
- ) ,
4624
- self . param_env ,
4625
- & bounds,
4626
- ) . into_iter ( ) . enumerate ( ) {
4627
- // This makes the error point at the bound, but we want to point at the argument
4628
- if let Some ( span) = spans. get ( i) {
4629
- obligation. cause . code = traits:: BindingObligation ( def_id, * span) ;
4630
- }
4631
- self . register_predicate ( obligation) ;
4632
- }
4614
+ self . add_required_obligations ( span, def_id, & substs) ;
4633
4615
4634
4616
// Substitute the values for the type parameters into the type of
4635
4617
// the referenced item.
@@ -4666,6 +4648,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4666
4648
( ty_substituted, res)
4667
4649
}
4668
4650
4651
+ /// Add all the obligations that are required, substituting and normalized appropriately.
4652
+ fn add_required_obligations ( & self , span : Span , def_id : DefId , substs : & SubstsRef < ' tcx > ) {
4653
+ let ( bounds, spans) = self . instantiate_bounds ( span, def_id, & substs) ;
4654
+
4655
+ for ( i, mut obligation) in traits:: predicates_for_generics (
4656
+ traits:: ObligationCause :: new (
4657
+ span,
4658
+ self . body_id ,
4659
+ traits:: ItemObligation ( def_id) ,
4660
+ ) ,
4661
+ self . param_env ,
4662
+ & bounds,
4663
+ ) . into_iter ( ) . enumerate ( ) {
4664
+ // This makes the error point at the bound, but we want to point at the argument
4665
+ if let Some ( span) = spans. get ( i) {
4666
+ obligation. cause . code = traits:: BindingObligation ( def_id, * span) ;
4667
+ }
4668
+ self . register_predicate ( obligation) ;
4669
+ }
4670
+ }
4671
+
4669
4672
fn check_rustc_args_require_const ( & self ,
4670
4673
def_id : DefId ,
4671
4674
hir_id : hir:: HirId ,
0 commit comments