@@ -279,8 +279,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
279279 /// fall back to subtyping (`unify_and`).
280280 fn coerce_from_inference_variable ( & self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
281281 debug ! ( "coerce_from_inference_variable(a={:?}, b={:?})" , a, b) ;
282- assert ! ( a. is_ty_var( ) && self . shallow_resolve( a) == a) ;
283- assert ! ( self . shallow_resolve( b) == b) ;
282+ debug_assert ! ( a. is_ty_var( ) && self . shallow_resolve( a) == a) ;
283+ debug_assert ! ( self . shallow_resolve( b) == b) ;
284284
285285 if b. is_ty_var ( ) {
286286 // Two unresolved type variables: create a `Coerce` predicate.
@@ -324,6 +324,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
324324 mutbl_b : hir:: Mutability ,
325325 ) -> CoerceResult < ' tcx > {
326326 debug ! ( "coerce_borrowed_pointer(a={:?}, b={:?})" , a, b) ;
327+ debug_assert ! ( self . shallow_resolve( a) == a) ;
328+ debug_assert ! ( self . shallow_resolve( b) == b) ;
327329
328330 // If we have a parameter of type `&M T_a` and the value
329331 // provided is `expr`, we will be adding an implicit borrow,
@@ -515,10 +517,10 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
515517 ///
516518 /// [unsized coercion](https://doc.rust-lang.org/reference/type-coercions.html#unsized-coercions)
517519 #[ instrument( skip( self ) , level = "debug" ) ]
518- fn coerce_unsized ( & self , mut source : Ty < ' tcx > , mut target : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
519- source = self . shallow_resolve ( source) ;
520- target = self . shallow_resolve ( target) ;
520+ fn coerce_unsized ( & self , source : Ty < ' tcx > , target : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
521521 debug ! ( ?source, ?target) ;
522+ debug_assert ! ( self . shallow_resolve( source) == source) ;
523+ debug_assert ! ( self . shallow_resolve( target) == target) ;
522524
523525 // We don't apply any coercions incase either the source or target
524526 // aren't sufficiently well known but tend to instead just equate
@@ -801,6 +803,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
801803 /// - `Pin<Box<T>>` as `Pin<&mut T>`
802804 #[ instrument( skip( self ) , level = "trace" ) ]
803805 fn coerce_pin_ref ( & self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
806+ debug_assert ! ( self . shallow_resolve( a) == a) ;
807+ debug_assert ! ( self . shallow_resolve( b) == b) ;
808+
804809 // We need to make sure the two types are compatible for coercion.
805810 // Then we will build a ReborrowPin adjustment and return that as an InferOk.
806811
@@ -849,6 +854,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
849854 b : Ty < ' tcx > ,
850855 adjustment : Option < Adjust > ,
851856 ) -> CoerceResult < ' tcx > {
857+ debug_assert ! ( self . shallow_resolve( b) == b) ;
858+
852859 self . commit_if_ok ( |snapshot| {
853860 let outer_universe = self . infcx . universe ( ) ;
854861
@@ -889,24 +896,19 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
889896 fn_ty_a : ty:: PolyFnSig < ' tcx > ,
890897 b : Ty < ' tcx > ,
891898 ) -> CoerceResult < ' tcx > {
892- //! Attempts to coerce from the type of a Rust function item
893- //! into a closure or a `proc`.
894- //!
895-
896- let b = self . shallow_resolve ( b) ;
897899 debug ! ( ?fn_ty_a, ?b, "coerce_from_fn_pointer" ) ;
900+ debug_assert ! ( self . shallow_resolve( b) == b) ;
898901
899902 self . coerce_from_safe_fn ( fn_ty_a, b, None )
900903 }
901904
902905 fn coerce_from_fn_item ( & self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
903- //! Attempts to coerce from the type of a Rust function item
904- //! into a closure or a `proc`.
906+ debug ! ( "coerce_from_fn_item(a={:?}, b={:?})" , a, b) ;
907+ debug_assert ! ( self . shallow_resolve( a) == a) ;
908+ debug_assert ! ( self . shallow_resolve( b) == b) ;
905909
906- let b = self . shallow_resolve ( b) ;
907910 let InferOk { value : b, mut obligations } =
908911 self . at ( & self . cause , self . param_env ) . normalize ( b) ;
909- debug ! ( "coerce_from_fn_item(a={:?}, b={:?})" , a, b) ;
910912
911913 match b. kind ( ) {
912914 ty:: FnPtr ( _, b_hdr) => {
@@ -956,18 +958,17 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
956958 }
957959 }
958960
961+ /// Attempts to coerce from the type of a non-capturing closure
962+ /// into a function pointer.
959963 fn coerce_closure_to_fn (
960964 & self ,
961965 a : Ty < ' tcx > ,
962966 closure_def_id_a : DefId ,
963967 args_a : GenericArgsRef < ' tcx > ,
964968 b : Ty < ' tcx > ,
965969 ) -> CoerceResult < ' tcx > {
966- //! Attempts to coerce from the type of a non-capturing closure
967- //! into a function pointer.
968- //!
969-
970- let b = self . shallow_resolve ( b) ;
970+ debug_assert ! ( self . shallow_resolve( a) == a) ;
971+ debug_assert ! ( self . shallow_resolve( b) == b) ;
971972
972973 match b. kind ( ) {
973974 // At this point we haven't done capture analysis, which means
@@ -1011,6 +1012,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
10111012 mutbl_b : hir:: Mutability ,
10121013 ) -> CoerceResult < ' tcx > {
10131014 debug ! ( "coerce_raw_ptr(a={:?}, b={:?})" , a, b) ;
1015+ debug_assert ! ( self . shallow_resolve( a) == a) ;
1016+ debug_assert ! ( self . shallow_resolve( b) == b) ;
10141017
10151018 let ( is_ref, mt_a) = match * a. kind ( ) {
10161019 ty:: Ref ( _, ty, mutbl) => ( true , ty:: TypeAndMut { ty, mutbl } ) ,
0 commit comments