@@ -216,7 +216,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
216
216
}
217
217
ty:: Adt ( pin, _)
218
218
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 ) =>
220
220
{
221
221
return self . coerce_pin ( a, b) ;
222
222
}
@@ -796,29 +796,29 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
796
796
// Then we will build a ReborrowPin adjustment and return that as an InferOk.
797
797
798
798
// 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 > | {
800
800
// Get the T out of Pin<T>
801
801
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 ) => {
803
803
args[ 0 ] . expect_ty ( )
804
804
}
805
805
_ => {
806
806
debug ! ( "can't reborrow {:?} as pinned" , ty) ;
807
- return None ;
807
+ return Err ( TypeError :: Mismatch ) ;
808
808
}
809
809
} ;
810
810
// Make sure the T is something we understand (just `&mut U` for now)
811
811
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) ) ,
813
813
_ => {
814
814
debug ! ( "can't reborrow pin of inner type {:?}" , ty) ;
815
- None
815
+ Err ( TypeError :: Mismatch )
816
816
}
817
817
}
818
818
} ;
819
819
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 ) ?;
822
822
823
823
// To complete the reborrow, we need to make sure we can unify the inner types, and if so we
824
824
// add the adjustments.
0 commit comments