@@ -215,7 +215,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
215
215
}
216
216
}
217
217
218
- // Examine the supertype and consider auto-borrowing.
218
+ // Examine the supertype and consider type-specific coercions, such
219
+ // as auto-borrowing, coercing pointer mutability, a `dyn*` coercion,
220
+ // or pin-ergonomics.
219
221
match * b. kind ( ) {
220
222
ty:: RawPtr ( _, b_mutbl) => {
221
223
return self . coerce_unsafe_ptr ( a, b, b_mutbl) ;
@@ -230,7 +232,10 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
230
232
if self . tcx . features ( ) . pin_ergonomics ( )
231
233
&& self . tcx . is_lang_item ( pin. did ( ) , hir:: LangItem :: Pin ) =>
232
234
{
233
- return self . coerce_pin ( a, b) ;
235
+ let pin_coerce = self . commit_if_ok ( |_| self . coerce_pin_ref ( a, b) ) ;
236
+ if pin_coerce. is_ok ( ) {
237
+ return pin_coerce;
238
+ }
234
239
}
235
240
_ => { }
236
241
}
@@ -797,7 +802,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
797
802
/// - `Pin<Box<T>>` as `Pin<&T>`
798
803
/// - `Pin<Box<T>>` as `Pin<&mut T>`
799
804
#[ instrument( skip( self ) , level = "trace" ) ]
800
- fn coerce_pin ( & self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
805
+ fn coerce_pin_ref ( & self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
801
806
// We need to make sure the two types are compatible for coercion.
802
807
// Then we will build a ReborrowPin adjustment and return that as an InferOk.
803
808
0 commit comments