@@ -981,21 +981,6 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
981
981
let ty_var = infcx
982
982
. next_ty_var ( TypeVariableOrigin { kind : TypeVariableOriginKind :: TypeInference , span } ) ;
983
983
984
- let item_bounds = tcx. explicit_item_bounds ( def_id) ;
985
- debug ! ( "instantiate_opaque_types: bounds={:#?}" , item_bounds) ;
986
- let bounds: Vec < _ > =
987
- item_bounds. iter ( ) . map ( |( bound, _) | bound. subst ( tcx, substs) ) . collect ( ) ;
988
-
989
- let param_env = tcx. param_env ( def_id) ;
990
- let InferOk { value : bounds, obligations } = infcx. partially_normalize_associated_types_in (
991
- ObligationCause :: misc ( span, self . body_id ) ,
992
- param_env,
993
- bounds,
994
- ) ;
995
- self . obligations . extend ( obligations) ;
996
-
997
- debug ! ( "instantiate_opaque_types: bounds={:?}" , bounds) ;
998
-
999
984
// Make sure that we are in fact defining the *entire* type
1000
985
// (e.g., `type Foo<T: Bound> = impl Bar;` needs to be
1001
986
// defined by a function like `fn foo<T: Bound>() -> Foo<T>`).
@@ -1015,6 +1000,21 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
1015
1000
) ;
1016
1001
debug ! ( "instantiate_opaque_types: ty_var={:?}" , ty_var) ;
1017
1002
1003
+ let item_bounds = tcx. explicit_item_bounds ( def_id) ;
1004
+ debug ! ( "instantiate_opaque_types: bounds={:#?}" , item_bounds) ;
1005
+ let bounds: Vec < _ > =
1006
+ item_bounds. iter ( ) . map ( |( bound, _) | bound. subst ( tcx, substs) ) . collect ( ) ;
1007
+
1008
+ let param_env = tcx. param_env ( def_id) ;
1009
+ let InferOk { value : bounds, obligations } = infcx. partially_normalize_associated_types_in (
1010
+ ObligationCause :: misc ( span, self . body_id ) ,
1011
+ param_env,
1012
+ bounds,
1013
+ ) ;
1014
+ self . obligations . extend ( obligations) ;
1015
+
1016
+ debug ! ( "instantiate_opaque_types: bounds={:?}" , bounds) ;
1017
+
1018
1018
for predicate in & bounds {
1019
1019
if let ty:: PredicateKind :: Projection ( projection) = predicate. kind ( ) . skip_binder ( ) {
1020
1020
if projection. ty . references_error ( ) {
0 commit comments