@@ -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 (
@@ -1277,6 +1282,32 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1277
1282
let lifetime = self . lower_lifetime ( & region) ;
1278
1283
hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) )
1279
1284
}
1285
+ TyKind :: PinnedRef ( region, mt) => {
1286
+ let region = region. unwrap_or_else ( || {
1287
+ let id = if let Some ( LifetimeRes :: ElidedAnchor { start, end } ) =
1288
+ self . resolver . get_lifetime_res ( t. id )
1289
+ {
1290
+ debug_assert_eq ! ( start. plus( 1 ) , end) ;
1291
+ start
1292
+ } else {
1293
+ self . next_node_id ( )
1294
+ } ;
1295
+ let span = self . tcx . sess . source_map ( ) . start_point ( t. span ) . shrink_to_hi ( ) ;
1296
+ Lifetime { ident : Ident :: new ( kw:: UnderscoreLifetime , span) , id }
1297
+ } ) ;
1298
+ let lifetime = self . lower_lifetime ( & region) ;
1299
+ let kind = hir:: TyKind :: Ref ( lifetime, self . lower_mt ( mt, itctx) ) ;
1300
+ let span = self . lower_span ( t. span ) ;
1301
+ let arg = hir:: Ty { kind, span, hir_id : self . next_id ( ) } ;
1302
+ let args = self . arena . alloc ( hir:: GenericArgs {
1303
+ args : self . arena . alloc ( [ hir:: GenericArg :: Type ( self . arena . alloc ( arg) ) ] ) ,
1304
+ constraints : & [ ] ,
1305
+ parenthesized : hir:: GenericArgsParentheses :: No ,
1306
+ span_ext : span,
1307
+ } ) ;
1308
+ let path = self . make_lang_item_qpath ( LangItem :: Pin , span, Some ( args) ) ;
1309
+ hir:: TyKind :: Path ( path)
1310
+ }
1280
1311
TyKind :: BareFn ( f) => {
1281
1312
let generic_params = self . lower_lifetime_binder ( t. id , & f. generic_params ) ;
1282
1313
hir:: TyKind :: BareFn ( self . arena . alloc ( hir:: BareFnTy {
@@ -1845,10 +1876,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1845
1876
// Given we are only considering `ImplicitSelf` types, we needn't consider
1846
1877
// the case where we have a mutable pattern to a reference as that would
1847
1878
// no longer be an `ImplicitSelf`.
1848
- TyKind :: Ref ( _, mt) if mt. ty . kind . is_implicit_self ( ) => match mt. mutbl {
1849
- hir:: Mutability :: Not => hir:: ImplicitSelfKind :: RefImm ,
1850
- hir:: Mutability :: Mut => hir:: ImplicitSelfKind :: RefMut ,
1851
- } ,
1879
+ TyKind :: Ref ( _, mt) | TyKind :: PinnedRef ( _, mt)
1880
+ if mt. ty . kind . is_implicit_self ( ) =>
1881
+ {
1882
+ match mt. mutbl {
1883
+ hir:: Mutability :: Not => hir:: ImplicitSelfKind :: RefImm ,
1884
+ hir:: Mutability :: Mut => hir:: ImplicitSelfKind :: RefMut ,
1885
+ }
1886
+ }
1852
1887
_ => hir:: ImplicitSelfKind :: None ,
1853
1888
}
1854
1889
} ) ,
0 commit comments