@@ -479,6 +479,31 @@ impl<'tcx> ThirBuildCx<'tcx> {
479
479
ExprKind :: RawBorrow { mutability, arg : self . mirror_expr ( arg) }
480
480
}
481
481
482
+ // Make `&pin mut $expr` and `&pin const $expr` into
483
+ // `Pin { __pointer: &mut $expr }` and `Pin { __pointer: &$expr }`.
484
+ hir:: ExprKind :: AddrOf ( hir:: BorrowKind :: Pin , mutbl, arg) => match expr_ty. kind ( ) {
485
+ & ty:: Adt ( adt_def, args)
486
+ if tcx. is_lang_item ( adt_def. did ( ) , rustc_hir:: LangItem :: Pin ) =>
487
+ {
488
+ let arg = self . mirror_expr ( arg) ;
489
+ let expr = self . thir . exprs . push ( Expr {
490
+ temp_lifetime : TempLifetime { temp_lifetime, backwards_incompatible } ,
491
+ ty : args. type_at ( 0 ) ,
492
+ span : expr. span ,
493
+ kind : ExprKind :: Borrow { borrow_kind : mutbl. to_borrow_kind ( ) , arg } ,
494
+ } ) ;
495
+ ExprKind :: Adt ( Box :: new ( AdtExpr {
496
+ adt_def,
497
+ variant_index : FIRST_VARIANT ,
498
+ args,
499
+ fields : Box :: new ( [ FieldExpr { name : FieldIdx :: from ( 0u32 ) , expr } ] ) ,
500
+ user_ty : None ,
501
+ base : AdtExprBase :: None ,
502
+ } ) )
503
+ }
504
+ _ => span_bug ! ( expr. span, "unexpected type for pinned borrow: {:?}" , expr_ty) ,
505
+ } ,
506
+
482
507
hir:: ExprKind :: Block ( blk, _) => ExprKind :: Block { block : self . mirror_block ( blk) } ,
483
508
484
509
hir:: ExprKind :: Assign ( lhs, rhs, _) => {
0 commit comments