mir_transform: implement forced inlining
Adds `#[rustc_force_inline]` which is similar to always inlining but reports an error if the inlining was not possible, and which always attempts to inline annotated items, regardless of optimisation levels. It can only be applied to free functions to guarantee that the MIR inliner will be able to resolve calls.
This commit is contained in:
@@ -11,6 +11,22 @@ pub enum InlineAttr {
|
||||
Hint,
|
||||
Always,
|
||||
Never,
|
||||
/// `#[rustc_force_inline]` forces inlining to happen in the MIR inliner - it reports an error
|
||||
/// if the inlining cannot happen. It is limited to only free functions so that the calls
|
||||
/// can always be resolved.
|
||||
Force {
|
||||
attr_span: Span,
|
||||
reason: Option<Symbol>,
|
||||
},
|
||||
}
|
||||
|
||||
impl InlineAttr {
|
||||
pub fn always(&self) -> bool {
|
||||
match self {
|
||||
InlineAttr::Always | InlineAttr::Force { .. } => true,
|
||||
InlineAttr::None | InlineAttr::Hint | InlineAttr::Never => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable_Generic)]
|
||||
|
||||
Reference in New Issue
Block a user