@@ -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;
@@ -765,8 +765,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
765
765
res
766
766
}
767
767
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) )
770
775
}
771
776
772
777
fn make_lang_item_path (
@@ -1317,6 +1322,32 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1317
1322
let lifetime = self . lower_lifetime ( & region) ;
1318
1323
hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) )
1319
1324
}
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
+ }
1320
1351
TyKind :: BareFn ( f) => {
1321
1352
let generic_params = self . lower_lifetime_binder ( t. id , & f. generic_params ) ;
1322
1353
hir:: TyKind :: BareFn ( self . arena . alloc ( hir:: BareFnTy {
@@ -1882,10 +1913,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1882
1913
// Given we are only considering `ImplicitSelf` types, we needn't consider
1883
1914
// the case where we have a mutable pattern to a reference as that would
1884
1915
// 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
+ }
1889
1924
_ => hir:: ImplicitSelfKind :: None ,
1890
1925
}
1891
1926
} ) ,
0 commit comments