@@ -216,7 +216,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
216216 }
217217 ty:: Adt ( pin, _)
218218 if self . tcx . features ( ) . pin_ergonomics
219- && pin . did ( ) == self . tcx . lang_items ( ) . pin_type ( ) . unwrap ( ) =>
219+ && self . tcx . is_lang_item ( pin . did ( ) , hir :: LangItem :: Pin ) =>
220220 {
221221 return self . coerce_pin ( a, b) ;
222222 }
@@ -796,29 +796,29 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
796796 // Then we will build a ReborrowPin adjustment and return that as an InferOk.
797797
798798 // Right now we can only reborrow if this is a `Pin<&mut T>`.
799- let can_reborrow = |ty : Ty < ' tcx > | {
799+ let extract_pin_mut = |ty : Ty < ' tcx > | {
800800 // Get the T out of Pin<T>
801801 let ty = match ty. kind ( ) {
802- ty:: Adt ( pin, args) if pin . did ( ) == self . tcx . lang_items ( ) . pin_type ( ) . unwrap ( ) => {
802+ ty:: Adt ( pin, args) if self . tcx . is_lang_item ( pin . did ( ) , hir :: LangItem :: Pin ) => {
803803 args[ 0 ] . expect_ty ( )
804804 }
805805 _ => {
806806 debug ! ( "can't reborrow {:?} as pinned" , ty) ;
807- return None ;
807+ return Err ( TypeError :: Mismatch ) ;
808808 }
809809 } ;
810810 // Make sure the T is something we understand (just `&mut U` for now)
811811 match ty. kind ( ) {
812- ty:: Ref ( region, ty, ty:: Mutability :: Mut ) => Some ( ( * region, * ty) ) ,
812+ ty:: Ref ( region, ty, ty:: Mutability :: Mut ) => Ok ( ( * region, * ty) ) ,
813813 _ => {
814814 debug ! ( "can't reborrow pin of inner type {:?}" , ty) ;
815- None
815+ Err ( TypeError :: Mismatch )
816816 }
817817 }
818818 } ;
819819
820- let ( _, _a_ty) = can_reborrow ( a ) . ok_or ( TypeError :: Mismatch ) ?;
821- let ( b_region, _b_ty) = can_reborrow ( b ) . ok_or ( TypeError :: Mismatch ) ?;
820+ let ( _, _a_ty) = extract_pin_mut ( a ) ?;
821+ let ( b_region, _b_ty) = extract_pin_mut ( b ) ?;
822822
823823 // To complete the reborrow, we need to make sure we can unify the inner types, and if so we
824824 // add the adjustments.
0 commit comments