@@ -155,6 +155,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
155155 }
156156
157157 /// Intern a type
158+ #[ inline( never) ]
158159 fn intern_ty (
159160 local : & CtxtInterners < ' tcx > ,
160161 global : & CtxtInterners < ' gcx > ,
@@ -216,6 +217,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
216217}
217218
218219pub struct CommonTypes < ' tcx > {
220+ pub unit : Ty < ' tcx > ,
219221 pub bool : Ty < ' tcx > ,
220222 pub char : Ty < ' tcx > ,
221223 pub isize : Ty < ' tcx > ,
@@ -832,7 +834,9 @@ impl<'tcx> CommonTypes<'tcx> {
832834 interners. region . borrow_mut ( ) . insert ( Interned ( r) ) ;
833835 & * r
834836 } ;
837+
835838 CommonTypes {
839+ unit : mk ( Tuple ( List :: empty ( ) ) ) ,
836840 bool : mk ( Bool ) ,
837841 char : mk ( Char ) ,
838842 never : mk ( Never ) ,
@@ -885,6 +889,7 @@ pub struct TyCtxt<'a, 'gcx: 'tcx, 'tcx: 'a> {
885889
886890impl < ' a , ' gcx , ' tcx > Deref for TyCtxt < ' a , ' gcx , ' tcx > {
887891 type Target = & ' a GlobalCtxt < ' gcx > ;
892+ #[ inline( always) ]
888893 fn deref ( & self ) -> & Self :: Target {
889894 & self . gcx
890895 }
@@ -2515,6 +2520,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
25152520 self . mk_fn_ptr ( converted_sig)
25162521 }
25172522
2523+ #[ inline]
25182524 pub fn mk_ty ( & self , st : TyKind < ' tcx > ) -> Ty < ' tcx > {
25192525 CtxtInterners :: intern_ty ( & self . interners , & self . global_interners , st)
25202526 }
@@ -2548,19 +2554,23 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
25482554 }
25492555 }
25502556
2557+ #[ inline]
25512558 pub fn mk_str ( self ) -> Ty < ' tcx > {
25522559 self . mk_ty ( Str )
25532560 }
25542561
2562+ #[ inline]
25552563 pub fn mk_static_str ( self ) -> Ty < ' tcx > {
25562564 self . mk_imm_ref ( self . types . re_static , self . mk_str ( ) )
25572565 }
25582566
2567+ #[ inline]
25592568 pub fn mk_adt ( self , def : & ' tcx AdtDef , substs : & ' tcx Substs < ' tcx > ) -> Ty < ' tcx > {
25602569 // take a copy of substs so that we own the vectors inside
25612570 self . mk_ty ( Adt ( def, substs) )
25622571 }
25632572
2573+ #[ inline]
25642574 pub fn mk_foreign ( self , def_id : DefId ) -> Ty < ' tcx > {
25652575 self . mk_ty ( Foreign ( def_id) )
25662576 }
@@ -2584,42 +2594,52 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
25842594 self . mk_ty ( Adt ( adt_def, substs) )
25852595 }
25862596
2597+ #[ inline]
25872598 pub fn mk_ptr ( self , tm : TypeAndMut < ' tcx > ) -> Ty < ' tcx > {
25882599 self . mk_ty ( RawPtr ( tm) )
25892600 }
25902601
2602+ #[ inline]
25912603 pub fn mk_ref ( self , r : Region < ' tcx > , tm : TypeAndMut < ' tcx > ) -> Ty < ' tcx > {
25922604 self . mk_ty ( Ref ( r, tm. ty , tm. mutbl ) )
25932605 }
25942606
2607+ #[ inline]
25952608 pub fn mk_mut_ref ( self , r : Region < ' tcx > , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
25962609 self . mk_ref ( r, TypeAndMut { ty : ty, mutbl : hir:: MutMutable } )
25972610 }
25982611
2612+ #[ inline]
25992613 pub fn mk_imm_ref ( self , r : Region < ' tcx > , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
26002614 self . mk_ref ( r, TypeAndMut { ty : ty, mutbl : hir:: MutImmutable } )
26012615 }
26022616
2617+ #[ inline]
26032618 pub fn mk_mut_ptr ( self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
26042619 self . mk_ptr ( TypeAndMut { ty : ty, mutbl : hir:: MutMutable } )
26052620 }
26062621
2622+ #[ inline]
26072623 pub fn mk_imm_ptr ( self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
26082624 self . mk_ptr ( TypeAndMut { ty : ty, mutbl : hir:: MutImmutable } )
26092625 }
26102626
2627+ #[ inline]
26112628 pub fn mk_nil_ptr ( self ) -> Ty < ' tcx > {
26122629 self . mk_imm_ptr ( self . mk_unit ( ) )
26132630 }
26142631
2632+ #[ inline]
26152633 pub fn mk_array ( self , ty : Ty < ' tcx > , n : u64 ) -> Ty < ' tcx > {
26162634 self . mk_ty ( Array ( ty, ty:: Const :: from_usize ( self , n) ) )
26172635 }
26182636
2637+ #[ inline]
26192638 pub fn mk_slice ( self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
26202639 self . mk_ty ( Slice ( ty) )
26212640 }
26222641
2642+ #[ inline]
26232643 pub fn intern_tup ( self , ts : & [ Ty < ' tcx > ] ) -> Ty < ' tcx > {
26242644 self . mk_ty ( Tuple ( self . intern_type_list ( ts) ) )
26252645 }
@@ -2628,10 +2648,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
26282648 iter. intern_with ( |ts| self . mk_ty ( Tuple ( self . intern_type_list ( ts) ) ) )
26292649 }
26302650
2651+ #[ inline]
26312652 pub fn mk_unit ( self ) -> Ty < ' tcx > {
2632- self . intern_tup ( & [ ] )
2653+ self . types . unit
26332654 }
26342655
2656+ #[ inline]
26352657 pub fn mk_diverging_default ( self ) -> Ty < ' tcx > {
26362658 if self . features ( ) . never_type {
26372659 self . types . never
@@ -2640,19 +2662,23 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
26402662 }
26412663 }
26422664
2665+ #[ inline]
26432666 pub fn mk_bool ( self ) -> Ty < ' tcx > {
26442667 self . mk_ty ( Bool )
26452668 }
26462669
2670+ #[ inline]
26472671 pub fn mk_fn_def ( self , def_id : DefId ,
26482672 substs : & ' tcx Substs < ' tcx > ) -> Ty < ' tcx > {
26492673 self . mk_ty ( FnDef ( def_id, substs) )
26502674 }
26512675
2676+ #[ inline]
26522677 pub fn mk_fn_ptr ( self , fty : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
26532678 self . mk_ty ( FnPtr ( fty) )
26542679 }
26552680
2681+ #[ inline]
26562682 pub fn mk_dynamic (
26572683 self ,
26582684 obj : ty:: Binder < & ' tcx List < ExistentialPredicate < ' tcx > > > ,
@@ -2661,6 +2687,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
26612687 self . mk_ty ( Dynamic ( obj, reg) )
26622688 }
26632689
2690+ #[ inline]
26642691 pub fn mk_projection ( self ,
26652692 item_def_id : DefId ,
26662693 substs : & ' tcx Substs < ' tcx > )
@@ -2671,11 +2698,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
26712698 } ) )
26722699 }
26732700
2701+ #[ inline]
26742702 pub fn mk_closure ( self , closure_id : DefId , closure_substs : ClosureSubsts < ' tcx > )
26752703 -> Ty < ' tcx > {
26762704 self . mk_ty ( Closure ( closure_id, closure_substs) )
26772705 }
26782706
2707+ #[ inline]
26792708 pub fn mk_generator ( self ,
26802709 id : DefId ,
26812710 generator_substs : GeneratorSubsts < ' tcx > ,
@@ -2684,32 +2713,39 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
26842713 self . mk_ty ( Generator ( id, generator_substs, movability) )
26852714 }
26862715
2716+ #[ inline]
26872717 pub fn mk_generator_witness ( self , types : ty:: Binder < & ' tcx List < Ty < ' tcx > > > ) -> Ty < ' tcx > {
26882718 self . mk_ty ( GeneratorWitness ( types) )
26892719 }
26902720
2721+ #[ inline]
26912722 pub fn mk_var ( self , v : TyVid ) -> Ty < ' tcx > {
26922723 self . mk_infer ( TyVar ( v) )
26932724 }
26942725
2726+ #[ inline]
26952727 pub fn mk_int_var ( self , v : IntVid ) -> Ty < ' tcx > {
26962728 self . mk_infer ( IntVar ( v) )
26972729 }
26982730
2731+ #[ inline]
26992732 pub fn mk_float_var ( self , v : FloatVid ) -> Ty < ' tcx > {
27002733 self . mk_infer ( FloatVar ( v) )
27012734 }
27022735
2736+ #[ inline]
27032737 pub fn mk_infer ( self , it : InferTy ) -> Ty < ' tcx > {
27042738 self . mk_ty ( Infer ( it) )
27052739 }
27062740
2741+ #[ inline]
27072742 pub fn mk_ty_param ( self ,
27082743 index : u32 ,
27092744 name : InternedString ) -> Ty < ' tcx > {
27102745 self . mk_ty ( Param ( ParamTy { idx : index, name : name } ) )
27112746 }
27122747
2748+ #[ inline]
27132749 pub fn mk_self_type ( self ) -> Ty < ' tcx > {
27142750 self . mk_ty_param ( 0 , keywords:: SelfType . name ( ) . as_interned_str ( ) )
27152751 }
@@ -2723,6 +2759,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
27232759 }
27242760 }
27252761
2762+ #[ inline]
27262763 pub fn mk_opaque ( self , def_id : DefId , substs : & ' tcx Substs < ' tcx > ) -> Ty < ' tcx > {
27272764 self . mk_ty ( Opaque ( def_id, substs) )
27282765 }
0 commit comments