@@ -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;
@@ -770,8 +770,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
770770 res
771771 }
772772
773- fn make_lang_item_qpath ( & mut self , lang_item : hir:: LangItem , span : Span ) -> hir:: QPath < ' hir > {
774- hir:: QPath :: Resolved ( None , self . make_lang_item_path ( lang_item, span, None ) )
773+ fn make_lang_item_qpath (
774+ & mut self ,
775+ lang_item : hir:: LangItem ,
776+ span : Span ,
777+ args : Option < & ' hir hir:: GenericArgs < ' hir > > ,
778+ ) -> hir:: QPath < ' hir > {
779+ hir:: QPath :: Resolved ( None , self . make_lang_item_path ( lang_item, span, args) )
775780 }
776781
777782 fn make_lang_item_path (
@@ -1322,6 +1327,32 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13221327 let lifetime = self . lower_lifetime ( & region) ;
13231328 hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) )
13241329 }
1330+ TyKind :: PinnedRef ( region, mt) => {
1331+ let region = region. unwrap_or_else ( || {
1332+ let id = if let Some ( LifetimeRes :: ElidedAnchor { start, end } ) =
1333+ self . resolver . get_lifetime_res ( t. id )
1334+ {
1335+ debug_assert_eq ! ( start. plus( 1 ) , end) ;
1336+ start
1337+ } else {
1338+ self . next_node_id ( )
1339+ } ;
1340+ let span = self . tcx . sess . source_map ( ) . start_point ( t. span ) . shrink_to_hi ( ) ;
1341+ Lifetime { ident : Ident :: new ( kw:: UnderscoreLifetime , span) , id }
1342+ } ) ;
1343+ let lifetime = self . lower_lifetime ( & region) ;
1344+ let kind = hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) ) ;
1345+ let span = self . lower_span ( t. span ) ;
1346+ let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) } ;
1347+ let args = self . arena . alloc ( hir:: GenericArgs {
1348+ args : self . arena . alloc ( [ hir:: GenericArg :: Type ( self . arena . alloc ( arg) ) ] ) ,
1349+ constraints : & [ ] ,
1350+ parenthesized : hir:: GenericArgsParentheses :: No ,
1351+ span_ext : span,
1352+ } ) ;
1353+ let path = self . make_lang_item_qpath ( LangItem :: Pin , span, Some ( args) ) ;
1354+ hir:: TyKind :: Path ( path)
1355+ }
13251356 TyKind :: BareFn ( f) => {
13261357 let generic_params = self . lower_lifetime_binder ( t. id , & f. generic_params ) ;
13271358 hir:: TyKind :: BareFn ( self . arena . alloc ( hir:: BareFnTy {
@@ -1904,10 +1935,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19041935 // Given we are only considering `ImplicitSelf` types, we needn't consider
19051936 // the case where we have a mutable pattern to a reference as that would
19061937 // no longer be an `ImplicitSelf`.
1907- TyKind :: Ref ( _, mt) if mt. ty . kind . is_implicit_self ( ) => match mt. mutbl {
1908- hir:: Mutability :: Not => hir:: ImplicitSelfKind :: RefImm ,
1909- hir:: Mutability :: Mut => hir:: ImplicitSelfKind :: RefMut ,
1910- } ,
1938+ TyKind :: Ref ( _, mt) | TyKind :: PinnedRef ( _, mt)
1939+ if mt. ty . kind . is_implicit_self ( ) =>
1940+ {
1941+ match mt. mutbl {
1942+ hir:: Mutability :: Not => hir:: ImplicitSelfKind :: RefImm ,
1943+ hir:: Mutability :: Mut => hir:: ImplicitSelfKind :: RefMut ,
1944+ }
1945+ }
19111946 _ => hir:: ImplicitSelfKind :: None ,
19121947 }
19131948 } ) ,
0 commit comments