diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-23 14:57:47 +0530 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-23 11:43:58 -0800 |
| commit | 3b69d1b941d61250735923f0cf957e1e3d86c4b4 (patch) | |
| tree | 20291b577f944e5ce2a6861cd08aaa4b4c0e23d9 /src/libsyntax | |
| parent | 3b4b90130fea3b2f5a8a52f2d19a3ace1c464efb (diff) | |
| parent | c9d0967383d67e2b51c222b17eb5502a8746aad0 (diff) | |
| download | rust-3b69d1b941d61250735923f0cf957e1e3d86c4b4.tar.gz rust-3b69d1b941d61250735923f0cf957e1e3d86c4b4.zip | |
Rollup merge of #22490 - nagisa:inline-args, r=alexcrichton
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 62e676891a0..4fc08c0c2b2 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -292,7 +292,7 @@ pub enum InlineAttr { } /// Determine what `#[inline]` attribute is present in `attrs`, if any. -pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr { +pub fn find_inline_attr(diagnostic: Option<&SpanHandler>, attrs: &[Attribute]) -> InlineAttr { // FIXME (#2809)---validate the usage of #[inline] and #[inline] attrs.iter().fold(InlineNone, |ia,attr| { match attr.node.value.node { @@ -302,12 +302,16 @@ pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr { } MetaList(ref n, ref items) if *n == "inline" => { mark_used(attr); - if contains_name(&items[..], "always") { + if items.len() != 1 { + diagnostic.map(|d|{ d.span_err(attr.span, "expected one argument"); }); + InlineNone + } else if contains_name(&items[..], "always") { InlineAlways } else if contains_name(&items[..], "never") { InlineNever } else { - InlineHint + diagnostic.map(|d|{ d.span_err((*items[0]).span, "invalid argument"); }); + InlineNone } } _ => ia @@ -317,7 +321,7 @@ 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) { + match find_inline_attr(None, attrs) { InlineHint | InlineAlways => true, InlineNone | InlineNever => false, } |
