@@ -4642,25 +4642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
46424642 // First, store the "user substs" for later.
46434643 self . write_user_type_annotation_from_substs ( hir_id, def_id, substs, user_self_ty) ;
46444644
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) ;
46644646
46654647 // Substitute the values for the type parameters into the type of
46664648 // the referenced item.
@@ -4697,6 +4679,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
46974679 ( ty_substituted, res)
46984680 }
46994681
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+
47004703 fn check_rustc_args_require_const ( & self ,
47014704 def_id : DefId ,
47024705 hir_id : hir:: HirId ,
0 commit comments