diff options
| author | Stuart Pernsteiner <spernsteiner@mozilla.com> | 2014-08-01 12:27:12 -0700 |
|---|---|---|
| committer | Stuart Pernsteiner <spernsteiner@mozilla.com> | 2014-09-05 09:18:57 -0700 |
| commit | 73f8adcbc830b3099026832eadb1ee5f876e041b (patch) | |
| tree | 874582eb457b438645cbef6c8ce4e3cda57817dd /src/libsyntax | |
| parent | edc5cdcba2c217d3a4d75801190cc34096ee80c2 (diff) | |
| download | rust-73f8adcbc830b3099026832eadb1ee5f876e041b.tar.gz rust-73f8adcbc830b3099026832eadb1ee5f876e041b.zip | |
make separate compilation respect #[inline] attributes
Adjust the handling of `#[inline]` items so that they get translated into every compilation unit that uses them. This is necessary to preserve the semantics of `#[inline(always)]`. Crate-local `#[inline]` functions and statics are blindly translated into every compilation unit. Cross-crate inlined items and monomorphizations of `#[inline]` functions are translated the first time a reference is seen in each compilation unit. When using multiple compilation units, inlined items are given `available_externally` linkage whenever possible to avoid duplicating object code.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index c234bea0a33..dd422d02149 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -280,7 +280,7 @@ pub enum InlineAttr { InlineNever, } -/// True if something like #[inline] is found in the list of attrs. +/// Determine what `#[inline]` attribute is present in `attrs`, if any. pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr { // FIXME (#2809)---validate the usage of #[inline] and #[inline] attrs.iter().fold(InlineNone, |ia,attr| { @@ -304,6 +304,14 @@ pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr { }) } +/// True if `#[inline]` or `#[inline(always)]` is present in `attrs`. +pub fn requests_inline(attrs: &[Attribute]) -> bool { + match find_inline_attr(attrs) { + InlineHint | InlineAlways => true, + InlineNone | InlineNever => false, + } +} + /// Tests if any `cfg(...)` meta items in `metas` match `cfg`. e.g. /// /// test_cfg(`[foo="a", bar]`, `[cfg(foo), cfg(bar)]`) == true |
