diff options
| author | Wesley Wiser <wwiser@gmail.com> | 2018-01-30 22:39:23 -0500 |
|---|---|---|
| committer | Wesley Wiser <wwiser@gmail.com> | 2018-03-06 19:58:02 -0500 |
| commit | 4f840a683aebb40a4eec0285a49962dfbc8f425b (patch) | |
| tree | 42a46993b1e9c9ecd2658f41aa4cc29bbf3e012d /src/libsyntax | |
| parent | e8cd6cc23783a6a020d2c14f1a0f343a6267195d (diff) | |
| download | rust-4f840a683aebb40a4eec0285a49962dfbc8f425b.tar.gz rust-4f840a683aebb40a4eec0285a49962dfbc8f425b.zip | |
Add `inline` to `TransFnAttrs`
Part of #47320
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 46 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic_list.rs | 69 |
2 files changed, 1 insertions, 114 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index d0822b69aa6..4818248129e 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -520,7 +520,7 @@ pub fn find_crate_name(attrs: &[Attribute]) -> Option<Symbol> { first_attr_value_str_by_name(attrs, "crate_name") } -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, Hash, PartialEq, RustcEncodable, RustcDecodable)] pub enum InlineAttr { None, Hint, @@ -528,43 +528,6 @@ pub enum InlineAttr { Never, } -/// Determine what `#[inline]` attribute is present in `attrs`, if any. -pub fn find_inline_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> InlineAttr { - attrs.iter().fold(InlineAttr::None, |ia, attr| { - if attr.path != "inline" { - return ia; - } - let meta = match attr.meta() { - Some(meta) => meta.node, - None => return ia, - }; - match meta { - MetaItemKind::Word => { - mark_used(attr); - InlineAttr::Hint - } - MetaItemKind::List(ref items) => { - mark_used(attr); - if items.len() != 1 { - diagnostic.map(|d|{ span_err!(d, attr.span, E0534, "expected one argument"); }); - InlineAttr::None - } else if list_contains_name(&items[..], "always") { - InlineAttr::Always - } else if list_contains_name(&items[..], "never") { - InlineAttr::Never - } else { - diagnostic.map(|d| { - span_err!(d, items[0].span, E0535, "invalid argument"); - }); - - InlineAttr::None - } - } - _ => ia, - } - }) -} - #[derive(Copy, Clone, PartialEq)] pub enum UnwindAttr { Allowed, @@ -610,13 +573,6 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op }) } -/// True if `#[inline]` or `#[inline(always)]` is present in `attrs`. -pub fn requests_inline(attrs: &[Attribute]) -> bool { - match find_inline_attr(None, attrs) { - InlineAttr::Hint | InlineAttr::Always => true, - InlineAttr::None | InlineAttr::Never => false, - } -} /// Tests if a cfg-pattern matches the cfg set pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Features>) -> bool { diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index 84ab0336f16..549ef88afcc 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -37,75 +37,6 @@ More details can be found in [RFC 438]. [RFC 438]: https://github.com/rust-lang/rfcs/pull/438 "##, -E0534: r##" -The `inline` attribute was malformed. - -Erroneous code example: - -```ignore (compile_fail not working here; see Issue #43707) -#[inline()] // error: expected one argument -pub fn something() {} - -fn main() {} -``` - -The parenthesized `inline` attribute requires the parameter to be specified: - -``` -#[inline(always)] -fn something() {} -``` - -or: - -``` -#[inline(never)] -fn something() {} -``` - -Alternatively, a paren-less version of the attribute may be used to hint the -compiler about inlining opportunity: - -``` -#[inline] -fn something() {} -``` - -For more information about the inline attribute, read: -https://doc.rust-lang.org/reference.html#inline-attributes -"##, - -E0535: r##" -An unknown argument was given to the `inline` attribute. - -Erroneous code example: - -```ignore (compile_fail not working here; see Issue #43707) -#[inline(unknown)] // error: invalid argument -pub fn something() {} - -fn main() {} -``` - -The `inline` attribute only supports two arguments: - - * always - * never - -All other arguments given to the `inline` attribute will return this error. -Example: - -``` -#[inline(never)] // ok! -pub fn something() {} - -fn main() {} -``` - -For more information about the inline attribute, https: -read://doc.rust-lang.org/reference.html#inline-attributes -"##, - E0536: r##" The `not` cfg-predicate was malformed. |
