@@ -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 (
@@ -1317,6 +1322,32 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13171322 let lifetime = self . lower_lifetime ( & region) ;
13181323 hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) )
13191324 }
1325+ TyKind :: PinnedRef ( region, mt) => {
1326+ let region = region. unwrap_or_else ( || {
1327+ let id = if let Some ( LifetimeRes :: ElidedAnchor { start, end } ) =
1328+ self . resolver . get_lifetime_res ( t. id )
1329+ {
1330+ debug_assert_eq ! ( start. plus( 1 ) , end) ;
1331+ start
1332+ } else {
1333+ self . next_node_id ( )
1334+ } ;
1335+ let span = self . tcx . sess . source_map ( ) . start_point ( t. span ) . shrink_to_hi ( ) ;
1336+ Lifetime { ident : Ident :: new ( kw:: UnderscoreLifetime , span) , id }
1337+ } ) ;
1338+ let lifetime = self . lower_lifetime ( & region) ;
1339+ let kind = hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) ) ;
1340+ let span = self . lower_span ( t. span ) ;
1341+ let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) } ;
1342+ let args = self . arena . alloc ( hir:: GenericArgs {
1343+ args : self . arena . alloc ( [ hir:: GenericArg :: Type ( self . arena . alloc ( arg) ) ] ) ,
1344+ constraints : & [ ] ,
1345+ parenthesized : hir:: GenericArgsParentheses :: No ,
1346+ span_ext : span,
1347+ } ) ;
1348+ let path = self . make_lang_item_qpath ( LangItem :: Pin , span, Some ( args) ) ;
1349+ hir:: TyKind :: Path ( path)
1350+ }
13201351 TyKind :: BareFn ( f) => {
13211352 let generic_params = self . lower_lifetime_binder ( t. id , & f. generic_params ) ;
13221353 hir:: TyKind :: BareFn ( self . arena . alloc ( hir:: BareFnTy {
@@ -1882,10 +1913,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18821913 // Given we are only considering `ImplicitSelf` types, we needn't consider
18831914 // the case where we have a mutable pattern to a reference as that would
18841915 // no longer be an `ImplicitSelf`.
1885- TyKind :: Ref ( _, mt) if mt. ty . kind . is_implicit_self ( ) => match mt. mutbl {
1886- hir:: Mutability :: Not => hir:: ImplicitSelfKind :: RefImm ,
1887- hir:: Mutability :: Mut => hir:: ImplicitSelfKind :: RefMut ,
1888- } ,
1916+ TyKind :: Ref ( _, mt) | TyKind :: PinnedRef ( _, mt)
1917+ if mt. ty . kind . is_implicit_self ( ) =>
1918+ {
1919+ match mt. mutbl {
1920+ hir:: Mutability :: Not => hir:: ImplicitSelfKind :: RefImm ,
1921+ hir:: Mutability :: Mut => hir:: ImplicitSelfKind :: RefMut ,
1922+ }
1923+ }
18891924 _ => hir:: ImplicitSelfKind :: None ,
18901925 }
18911926 } ) ,
0 commit comments