@@ -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:: { LocalDefId , LocalDefIdMap , CRATE_DEF_ID , LOCAL_CRATE } ;
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;
@@ -756,8 +756,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
756756 res
757757 }
758758
759- fn make_lang_item_qpath ( & mut self , lang_item : hir:: LangItem , span : Span ) -> hir:: QPath < ' hir > {
760- hir:: QPath :: Resolved ( None , self . make_lang_item_path ( lang_item, span, None ) )
759+ fn make_lang_item_qpath (
760+ & mut self ,
761+ lang_item : hir:: LangItem ,
762+ span : Span ,
763+ args : Option < & ' hir hir:: GenericArgs < ' hir > > ,
764+ ) -> hir:: QPath < ' hir > {
765+ hir:: QPath :: Resolved ( None , self . make_lang_item_path ( lang_item, span, args) )
761766 }
762767
763768 fn make_lang_item_path (
@@ -1284,7 +1289,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12841289 }
12851290 TyKind :: Slice ( ty) => hir:: TyKind :: Slice ( self . lower_ty ( ty, itctx) ) ,
12861291 TyKind :: Ptr ( mt) => hir:: TyKind :: Ptr ( self . lower_mt ( mt, itctx) ) ,
1287- TyKind :: Ref ( region, mt) => {
1292+ TyKind :: Ref ( region, pinned , mt) => {
12881293 let region = region. unwrap_or_else ( || {
12891294 let id = if let Some ( LifetimeRes :: ElidedAnchor { start, end } ) =
12901295 self . resolver . get_lifetime_res ( t. id )
@@ -1298,7 +1303,22 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12981303 Lifetime { ident : Ident :: new ( kw:: UnderscoreLifetime , span) , id }
12991304 } ) ;
13001305 let lifetime = self . lower_lifetime ( & region) ;
1301- hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) )
1306+ let kind = hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) ) ;
1307+ match pinned {
1308+ Pinnedness :: Not => kind,
1309+ Pinnedness :: Pinned => {
1310+ let span = self . lower_span ( t. span ) ;
1311+ let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) } ;
1312+ let args = self . arena . alloc ( hir:: GenericArgs {
1313+ args : self . arena . alloc ( [ hir:: GenericArg :: Type ( self . arena . alloc ( arg) ) ] ) ,
1314+ constraints : & [ ] ,
1315+ parenthesized : hir:: GenericArgsParentheses :: No ,
1316+ span_ext : span,
1317+ } ) ;
1318+ let path = self . make_lang_item_qpath ( LangItem :: Pin , span, Some ( args) ) ;
1319+ hir:: TyKind :: Path ( path)
1320+ }
1321+ }
13021322 }
13031323 TyKind :: BareFn ( f) => {
13041324 let generic_params = self . lower_lifetime_binder ( t. id , & f. generic_params ) ;
@@ -1882,7 +1902,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18821902 // Given we are only considering `ImplicitSelf` types, we needn't consider
18831903 // the case where we have a mutable pattern to a reference as that would
18841904 // no longer be an `ImplicitSelf`.
1885- TyKind :: Ref ( _, mt) if mt. ty . kind . is_implicit_self ( ) => match mt. mutbl {
1905+ TyKind :: Ref ( _, _ , mt) if mt. ty . kind . is_implicit_self ( ) => match mt. mutbl {
18861906 hir:: Mutability :: Not => hir:: ImplicitSelfKind :: RefImm ,
18871907 hir:: Mutability :: Mut => hir:: ImplicitSelfKind :: RefMut ,
18881908 } ,
0 commit comments