@@ -55,8 +55,8 @@ use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
55
55
use rustc_hir:: def:: { DefKind , LifetimeRes , Namespace , PartialRes , PerNS , Res } ;
56
56
use rustc_hir:: def_id:: { CRATE_DEF_ID , LOCAL_CRATE , LocalDefId , LocalDefIdMap } ;
57
57
use 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 ,
60
60
} ;
61
61
use rustc_index:: { Idx , IndexSlice , IndexVec } ;
62
62
use rustc_macros:: extension;
@@ -770,8 +770,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
770
770
res
771
771
}
772
772
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) )
775
780
}
776
781
777
782
fn make_lang_item_path (
@@ -1322,6 +1327,32 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1322
1327
let lifetime = self . lower_lifetime ( & region) ;
1323
1328
hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) )
1324
1329
}
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
+ }
1325
1356
TyKind :: BareFn ( f) => {
1326
1357
let generic_params = self . lower_lifetime_binder ( t. id , & f. generic_params ) ;
1327
1358
hir:: TyKind :: BareFn ( self . arena . alloc ( hir:: BareFnTy {
@@ -1904,10 +1935,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1904
1935
// Given we are only considering `ImplicitSelf` types, we needn't consider
1905
1936
// the case where we have a mutable pattern to a reference as that would
1906
1937
// 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
+ }
1911
1946
_ => hir:: ImplicitSelfKind :: None ,
1912
1947
}
1913
1948
} ) ,
0 commit comments