Skip to content

Commit 4cce4ff

Browse files
committed
Add inline attributes and add unit to CommonTypes
1 parent 3dde9e1 commit 4cce4ff

File tree

9 files changed

+57
-1
lines changed

9 files changed

+57
-1
lines changed

src/libcore/num/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3614,6 +3614,7 @@ assert_eq!(3", stringify!($SelfT), ".checked_next_power_of_two(), Some(4));
36143614
assert_eq!(", stringify!($SelfT), "::max_value().checked_next_power_of_two(), None);",
36153615
$EndFeature, "
36163616
```"),
3617+
#[inline]
36173618
#[stable(feature = "rust1", since = "1.0.0")]
36183619
pub fn checked_next_power_of_two(self) -> Option<Self> {
36193620
self.one_less_than_next_power_of_two().checked_add(1)

src/librustc/infer/at.rs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub struct Trace<'a, 'gcx: 'tcx, 'tcx: 'a> {
5252
}
5353

5454
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
55+
#[inline]
5556
pub fn at(&'a self,
5657
cause: &'a ObligationCause<'tcx>,
5758
param_env: ty::ParamEnv<'tcx>)

src/librustc/infer/resolve.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct OpportunisticTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
2525
}
2626

2727
impl<'a, 'gcx, 'tcx> OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
28+
#[inline]
2829
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
2930
OpportunisticTypeResolver { infcx }
3031
}

src/librustc/traits/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ impl<'tcx,O> Obligation<'tcx,O> {
10521052
}
10531053

10541054
impl<'tcx> ObligationCause<'tcx> {
1055+
#[inline]
10551056
pub fn new(span: Span,
10561057
body_id: ast::NodeId,
10571058
code: ObligationCauseCode<'tcx>)

src/librustc/ty/context.rs

+38-1
Original file line numberDiff line numberDiff line change
@@ -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

218219
pub 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

886890
impl<'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
}

src/librustc/ty/fold.rs

+1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
374374
}
375375

376376
impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
377+
#[inline]
377378
pub fn new(
378379
tcx: TyCtxt<'a, 'gcx, 'tcx>,
379380
skipped_regions: &'a mut bool,

src/librustc/ty/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,7 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
12751275
self.skip_binder().projection_ty.item_def_id
12761276
}
12771277

1278+
#[inline]
12781279
pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'_, '_, '_>) -> PolyTraitRef<'tcx> {
12791280
// Note: unlike with `TraitRef::to_poly_trait_ref()`,
12801281
// `self.0.trait_ref` is permitted to have escaping regions.
@@ -1633,6 +1634,7 @@ impl<'tcx> ParamEnv<'tcx> {
16331634
/// there are no where clauses in scope. Hidden types (like `impl
16341635
/// Trait`) are left hidden, so this is suitable for ordinary
16351636
/// type-checking.
1637+
#[inline]
16361638
pub fn empty() -> Self {
16371639
Self::new(List::empty(), Reveal::UserFacing)
16381640
}
@@ -1644,11 +1646,13 @@ impl<'tcx> ParamEnv<'tcx> {
16441646
///
16451647
/// N.B. If you want to have predicates in scope, use `ParamEnv::new`,
16461648
/// or invoke `param_env.with_reveal_all()`.
1649+
#[inline]
16471650
pub fn reveal_all() -> Self {
16481651
Self::new(List::empty(), Reveal::All)
16491652
}
16501653

16511654
/// Construct a trait environment with the given set of predicates.
1655+
#[inline]
16521656
pub fn new(caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
16531657
reveal: Reveal)
16541658
-> Self {
@@ -2148,6 +2152,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
21482152
}
21492153
}
21502154

2155+
#[inline]
21512156
pub fn variant_descr(&self) -> &'static str {
21522157
match self.adt_kind() {
21532158
AdtKind::Struct => "struct",

src/librustc/ty/sty.rs

+8
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ impl<'tcx> TraitRef<'tcx> {
667667
}
668668
}
669669

670+
#[inline]
670671
pub fn self_ty(&self) -> Ty<'tcx> {
671672
self.substs.type_at(0)
672673
}
@@ -978,15 +979,18 @@ impl<'tcx> FnSig<'tcx> {
978979
pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>;
979980

980981
impl<'tcx> PolyFnSig<'tcx> {
982+
#[inline]
981983
pub fn inputs(&self) -> Binder<&'tcx [Ty<'tcx>]> {
982984
self.map_bound_ref(|fn_sig| fn_sig.inputs())
983985
}
986+
#[inline]
984987
pub fn input(&self, index: usize) -> ty::Binder<Ty<'tcx>> {
985988
self.map_bound_ref(|fn_sig| fn_sig.inputs()[index])
986989
}
987990
pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List<Ty<'tcx>>> {
988991
self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output)
989992
}
993+
#[inline]
990994
pub fn output(&self) -> ty::Binder<Ty<'tcx>> {
991995
self.map_bound_ref(|fn_sig| fn_sig.output())
992996
}
@@ -1548,6 +1552,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
15481552
}
15491553
}
15501554

1555+
#[inline]
15511556
pub fn is_ty_var(&self) -> bool {
15521557
match self.sty {
15531558
Infer(TyVar(_)) => true,
@@ -1732,6 +1737,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
17321737
}
17331738
}
17341739

1740+
#[inline]
17351741
pub fn is_integral(&self) -> bool {
17361742
match self.sty {
17371743
Infer(IntVar(_)) | Int(_) | Uint(_) => true,
@@ -1762,6 +1768,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
17621768
}
17631769
}
17641770

1771+
#[inline]
17651772
pub fn is_fp(&self) -> bool {
17661773
match self.sty {
17671774
Infer(FloatVar(_)) | Float(_) => true,
@@ -1845,6 +1852,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
18451852
}
18461853
}
18471854

1855+
#[inline]
18481856
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
18491857
match self.sty {
18501858
Adt(adt, _) => Some(adt),

src/libsyntax_pos/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ impl fmt::Debug for SpanData {
587587
}
588588

589589
impl MultiSpan {
590+
#[inline]
590591
pub fn new() -> MultiSpan {
591592
MultiSpan {
592593
primary_spans: vec![],

0 commit comments

Comments
 (0)