Skip to content

Commit ca09339

Browse files
committed
Inline or const some hot functions
1 parent 7bb820b commit ca09339

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

compiler/rustc_hir/src/hir.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,6 +4076,7 @@ impl FnDeclFlags {
40764076
}
40774077

40784078
/// Returns `true` if the given input contains a `#[splat]` attribute in `attrs`.
4079+
#[inline]
40794080
pub fn is_splatted_arg<'hir>(
40804081
&self,
40814082
input: &'hir Ty<'hir>,
@@ -4086,6 +4087,7 @@ impl FnDeclFlags {
40864087

40874088
/// Searches `inputs` and `attrs` for the index of the splatted argument. Returns `None` if
40884089
/// there is no splatted argument.
4090+
#[inline]
40894091
pub fn splatted_arg_index<'hir>(
40904092
&self,
40914093
inputs: &'hir [Ty<'hir>],
@@ -4138,24 +4140,25 @@ impl<'hir> FnDecl<'hir> {
41384140
None
41394141
}
41404142

4141-
pub fn implicit_self(&self) -> ImplicitSelfKind {
4143+
pub const fn implicit_self(&self) -> ImplicitSelfKind {
41424144
self.fn_decl_kind.implicit_self()
41434145
}
41444146

4145-
pub fn c_variadic(&self) -> bool {
4147+
pub const fn c_variadic(&self) -> bool {
41464148
self.fn_decl_kind.c_variadic()
41474149
}
41484150

4149-
pub fn lifetime_elision_allowed(&self) -> bool {
4151+
pub const fn lifetime_elision_allowed(&self) -> bool {
41504152
self.fn_decl_kind.lifetime_elision_allowed()
41514153
}
41524154

41534155
/// Returns `true` if the function has a splatted argument.
4154-
pub fn has_splatted_arg(&self) -> bool {
4156+
pub const fn has_splatted_arg(&self) -> bool {
41554157
self.fn_decl_kind.has_splatted_arg()
41564158
}
41574159

41584160
/// Returns `true` if the given argument `index` contains a `#[splat]` attribute in `attrs`.
4161+
#[inline]
41594162
pub fn is_splatted_arg(
41604163
&self,
41614164
index: usize,
@@ -4166,14 +4169,17 @@ impl<'hir> FnDecl<'hir> {
41664169

41674170
/// Searches `self.inputs` and `attrs` for the index of the splatted argument. Returns `None`
41684171
/// if there is no splatted argument.
4172+
#[inline]
41694173
pub fn splatted_arg_index(
41704174
&self,
41714175
attrs: &'hir dyn Fn(HirId) -> &'hir [Attribute],
41724176
) -> Option<u16> {
41734177
self.fn_decl_kind.splatted_arg_index(self.inputs, attrs)
41744178
}
41754179

4176-
pub fn dummy(span: Span) -> Self {
4180+
/// Returns a dummy FnDecl with the given span, no inputs, no output, and lifetime elision
4181+
/// allowed.
4182+
pub const fn dummy(span: Span) -> Self {
41774183
Self {
41784184
inputs: &[],
41794185
output: FnRetTy::DefaultReturn(span),
@@ -4200,7 +4206,7 @@ pub enum ImplicitSelfKind {
42004206

42014207
impl ImplicitSelfKind {
42024208
/// Does this represent an implicit self?
4203-
pub fn has_implicit_self(&self) -> bool {
4209+
pub const fn has_implicit_self(&self) -> bool {
42044210
!matches!(*self, ImplicitSelfKind::None)
42054211
}
42064212
}

0 commit comments

Comments
 (0)