@@ -55,8 +55,8 @@ use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
5555use rustc_hir:: def:: { DefKind , LifetimeRes , Namespace , PartialRes , PerNS , Res } ;
5656use rustc_hir:: def_id:: { CRATE_DEF_ID , LOCAL_CRATE , LocalDefId , LocalDefIdMap } ;
5757use rustc_hir:: {
58- self as hir, ConstArg , GenericArg , HirId , ItemLocalMap , MissingLifetimeKind , ParamName ,
59- TraitCandidate ,
58+ self as hir, ConstArg , GenericArg , HirId , ItemLocalMap , LangItem , MissingLifetimeKind ,
59+ ParamName , TraitCandidate ,
6060} ;
6161use rustc_index:: { Idx , IndexSlice , IndexVec } ;
6262use rustc_macros:: extension;
@@ -765,8 +765,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
765765 res
766766 }
767767
768- fn make_lang_item_qpath ( & mut self , lang_item : hir:: LangItem , span : Span ) -> hir:: QPath < ' hir > {
769- hir:: QPath :: Resolved ( None , self . make_lang_item_path ( lang_item, span, None ) )
768+ fn make_lang_item_qpath (
769+ & mut self ,
770+ lang_item : hir:: LangItem ,
771+ span : Span ,
772+ args : Option < & ' hir hir:: GenericArgs < ' hir > > ,
773+ ) -> hir:: QPath < ' hir > {
774+ hir:: QPath :: Resolved ( None , self . make_lang_item_path ( lang_item, span, args) )
770775 }
771776
772777 fn make_lang_item_path (
@@ -1277,6 +1282,32 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12771282 let lifetime = self . lower_lifetime ( & region) ;
12781283 hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) )
12791284 }
1285+ TyKind :: PinnedRef ( region, mt) => {
1286+ let region = region. unwrap_or_else ( || {
1287+ let id = if let Some ( LifetimeRes :: ElidedAnchor { start, end } ) =
1288+ self . resolver . get_lifetime_res ( t. id )
1289+ {
1290+ debug_assert_eq ! ( start. plus( 1 ) , end) ;
1291+ start
1292+ } else {
1293+ self . next_node_id ( )
1294+ } ;
1295+ let span = self . tcx . sess . source_map ( ) . start_point ( t. span ) . shrink_to_hi ( ) ;
1296+ Lifetime { ident : Ident :: new ( kw:: UnderscoreLifetime , span) , id }
1297+ } ) ;
1298+ let lifetime = self . lower_lifetime ( & region) ;
1299+ let kind = hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) ) ;
1300+ let span = self . lower_span ( t. span ) ;
1301+ let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) } ;
1302+ let args = self . arena . alloc ( hir:: GenericArgs {
1303+ args : self . arena . alloc ( [ hir:: GenericArg :: Type ( self . arena . alloc ( arg) ) ] ) ,
1304+ constraints : & [ ] ,
1305+ parenthesized : hir:: GenericArgsParentheses :: No ,
1306+ span_ext : span,
1307+ } ) ;
1308+ let path = self . make_lang_item_qpath ( LangItem :: Pin , span, Some ( args) ) ;
1309+ hir:: TyKind :: Path ( path)
1310+ }
12801311 TyKind :: BareFn ( f) => {
12811312 let generic_params = self . lower_lifetime_binder ( t. id , & f. generic_params ) ;
12821313 hir:: TyKind :: BareFn ( self . arena . alloc ( hir:: BareFnTy {
@@ -1845,10 +1876,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18451876 // Given we are only considering `ImplicitSelf` types, we needn't consider
18461877 // the case where we have a mutable pattern to a reference as that would
18471878 // no longer be an `ImplicitSelf`.
1848- TyKind :: Ref ( _, mt) if mt. ty . kind . is_implicit_self ( ) => match mt. mutbl {
1849- hir:: Mutability :: Not => hir:: ImplicitSelfKind :: RefImm ,
1850- hir:: Mutability :: Mut => hir:: ImplicitSelfKind :: RefMut ,
1851- } ,
1879+ TyKind :: Ref ( _, mt) | TyKind :: PinnedRef ( _, mt)
1880+ if mt. ty . kind . is_implicit_self ( ) =>
1881+ {
1882+ match mt. mutbl {
1883+ hir:: Mutability :: Not => hir:: ImplicitSelfKind :: RefImm ,
1884+ hir:: Mutability :: Mut => hir:: ImplicitSelfKind :: RefMut ,
1885+ }
1886+ }
18521887 _ => hir:: ImplicitSelfKind :: None ,
18531888 }
18541889 } ) ,
0 commit comments