diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-08-21 02:23:46 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-09-24 12:56:44 +0200 |
| commit | 7767e7fb165d527f1991175809a361f2d2313b80 (patch) | |
| tree | e2e776a76307c183bb2a762a2b1f630b71339b68 /src/libsyntax/attr | |
| parent | 7fdea7a72abb9f5a58fdc19c0a298042291c53b2 (diff) | |
| download | rust-7767e7fb165d527f1991175809a361f2d2313b80.tar.gz rust-7767e7fb165d527f1991175809a361f2d2313b80.zip | |
Stabilize `str::len`, `[T]::len`, `is_empty` and `str::as_bytes` as const fn
Diffstat (limited to 'src/libsyntax/attr')
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 1f954064944..9d06b926f97 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -433,6 +433,30 @@ pub fn find_by_name(attrs: &[Attribute], name: Symbol) -> Option<&Attribute> { attrs.iter().find(|attr| attr.check_name(name)) } +pub fn allow_internal_unstable<'a>( + attrs: &[Attribute], + span_diagnostic: &'a errors::Handler, +) -> Option<impl Iterator<Item = Symbol> + 'a> { + find_by_name(attrs, sym::allow_internal_unstable).and_then(|attr| { + attr.meta_item_list().or_else(|| { + span_diagnostic.span_err( + attr.span, + "allow_internal_unstable expects list of feature names" + ); + None + }).map(|features| features.into_iter().filter_map(move |it| { + let name = it.ident().map(|ident| ident.name); + if name.is_none() { + span_diagnostic.span_err( + it.span(), + "`allow_internal_unstable` expects feature names", + ) + } + name + })) + }) +} + pub fn filter_by_name(attrs: &[Attribute], name: Symbol) -> impl Iterator<Item=&Attribute> { attrs.iter().filter(move |attr| attr.check_name(name)) |
