use crate::hir::intravisit::{self, NestedVisitorMap, Visitor};
use syntax::symbol::Symbol;
use syntax::ast::{Attribute, MetaItem, MetaItemKind};
-use syntax_pos::Span;
+use syntax_pos::{Span, sym};
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
use rustc_macros::HashStable;
use errors::DiagnosticId;
}
fn extract(&self, attr: &Attribute) -> Option<(Symbol, Option<Symbol>, Span)> {
- let stab_attrs = vec!["stable", "unstable", "rustc_const_unstable"];
+ let stab_attrs = [sym::stable, sym::unstable, sym::rustc_const_unstable];
// Find a stability attribute (i.e., `#[stable (..)]`, `#[unstable (..)]`,
// `#[rustc_const_unstable (..)]`).
if let Some(stab_attr) = stab_attrs.iter().find(|stab_attr| {
- attr.check_name(stab_attr)
+ attr.check_name(**stab_attr)
}) {
let meta_item = attr.meta();
if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta_item {
for meta in metas {
if let Some(mi) = meta.meta_item() {
// Find the `feature = ".."` meta-item.
- match (mi.name_or_empty().get(), mi.value_str()) {
- ("feature", val) => feature = val,
- ("since", val) => since = val,
+ match (mi.name_or_empty(), mi.value_str()) {
+ (sym::feature, val) => feature = val,
+ (sym::since, val) => since = val,
_ => {}
}
}
// This additional check for stability is to make sure we
// don't emit additional, irrelevant errors for malformed
// attributes.
- if *stab_attr != "stable" || since.is_some() {
+ if *stab_attr != sym::stable || since.is_some() {
return Some((feature, since, attr.span));
}
}