diff options
| author | scalexm <martin.alex32@hotmail.fr> | 2017-09-20 20:42:49 +0200 |
|---|---|---|
| committer | scalexm <martin.alex32@hotmail.fr> | 2017-09-20 20:48:06 +0200 |
| commit | 3fa3fe01b65ec4dde20c66c6bedcd28e2f83f8b6 (patch) | |
| tree | 1eb75438d9833dee61d34237ae7c25e9758f7891 /src/libsyntax | |
| parent | f7964aebe516bc7e4f06f7128ebb39ad5576a1a7 (diff) | |
| download | rust-3fa3fe01b65ec4dde20c66c6bedcd28e2f83f8b6.tar.gz rust-3fa3fe01b65ec4dde20c66c6bedcd28e2f83f8b6.zip | |
Fix ICE
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 36ab3737f38..b1f796084df 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -500,6 +500,20 @@ pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str) -> Option<S .and_then(|at| at.value_str()) } +/// Check if `attrs` contains an attribute like `#![feature(feature_name)]`. +/// This will not perform any "sanity checks" on the form of the attributes. +pub fn contains_feature_attr(attrs: &[Attribute], feature_name: &str) -> bool { + attrs.iter().any(|item| { + item.check_name("feature") && + item.meta_item_list().map(|list| { + list.iter().any(|mi| { + mi.word().map(|w| w.name() == feature_name) + .unwrap_or(false) + }) + }).unwrap_or(false) + }) +} + /* Higher-level applications */ pub fn find_crate_name(attrs: &[Attribute]) -> Option<Symbol> { |
