@@ -4736,25 +4736,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4736
4736
// First, store the "user substs" for later.
4737
4737
self . write_user_type_annotation_from_substs ( hir_id, def_id, substs, user_self_ty) ;
4738
4738
4739
- // Add all the obligations that are required, substituting and
4740
- // normalized appropriately.
4741
- let ( bounds, spans) = self . instantiate_bounds ( span, def_id, & substs) ;
4742
-
4743
- for ( i, mut obligation) in traits:: predicates_for_generics (
4744
- traits:: ObligationCause :: new (
4745
- span,
4746
- self . body_id ,
4747
- traits:: ItemObligation ( def_id) ,
4748
- ) ,
4749
- self . param_env ,
4750
- & bounds,
4751
- ) . into_iter ( ) . enumerate ( ) {
4752
- // This makes the error point at the bound, but we want to point at the argument
4753
- if let Some ( span) = spans. get ( i) {
4754
- obligation. cause . code = traits:: BindingObligation ( def_id, * span) ;
4755
- }
4756
- self . register_predicate ( obligation) ;
4757
- }
4739
+ self . add_required_obligations ( span, def_id, & substs) ;
4758
4740
4759
4741
// Substitute the values for the type parameters into the type of
4760
4742
// the referenced item.
@@ -4791,6 +4773,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4791
4773
( ty_substituted, res)
4792
4774
}
4793
4775
4776
+ /// Add all the obligations that are required, substituting and normalized appropriately.
4777
+ fn add_required_obligations ( & self , span : Span , def_id : DefId , substs : & SubstsRef < ' tcx > ) {
4778
+ let ( bounds, spans) = self . instantiate_bounds ( span, def_id, & substs) ;
4779
+
4780
+ for ( i, mut obligation) in traits:: predicates_for_generics (
4781
+ traits:: ObligationCause :: new (
4782
+ span,
4783
+ self . body_id ,
4784
+ traits:: ItemObligation ( def_id) ,
4785
+ ) ,
4786
+ self . param_env ,
4787
+ & bounds,
4788
+ ) . into_iter ( ) . enumerate ( ) {
4789
+ // This makes the error point at the bound, but we want to point at the argument
4790
+ if let Some ( span) = spans. get ( i) {
4791
+ obligation. cause . code = traits:: BindingObligation ( def_id, * span) ;
4792
+ }
4793
+ self . register_predicate ( obligation) ;
4794
+ }
4795
+ }
4796
+
4794
4797
fn check_rustc_args_require_const ( & self ,
4795
4798
def_id : DefId ,
4796
4799
hir_id : hir:: HirId ,
0 commit comments