use session::Session;
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
use syntax::visit;
use syntax::visit::Visitor;
use std::cmp;
use std::default::Default as StdDefault;
use std::mem;
-use syntax::attr::{self, AttrMetaMethods};
+use syntax::attr;
use syntax::parse::token::InternedString;
use syntax::ast;
use syntax_pos::Span;
use util::nodemap::FnvHashMap;
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
use syntax::parse::token::InternedString;
use hir::intravisit::Visitor;
use hir;
use session::Session;
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
pub fn update_recursion_limit(sess: &Session, krate: &ast::Crate) {
for attr in &krate.attrs {
use syntax::ast;
use syntax::ast::{NodeId, Attribute};
use syntax::feature_gate::{GateIssue, emit_feature_err, find_lang_feature_accepted_version};
-use syntax::attr::{self, Stability, Deprecation, AttrMetaMethods};
+use syntax::attr::{self, Stability, Deprecation};
use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap};
use hir;
use syntax::ast::{self, IntTy, UintTy};
use syntax::attr;
-use syntax::attr::AttrMetaMethods;
use syntax::parse;
use syntax::parse::token::InternedString;
use syntax::feature_gate::UnstableFeatures;
use std::rc::Rc;
use super::{OutputType, OutputTypes, Externs, PanicStrategy};
use syntax::attr;
- use syntax::attr::AttrMetaMethods;
fn optgroups() -> Vec<OptGroup> {
super::rustc_optgroups().into_iter()
use std::cmp;
use std::fmt;
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
use syntax_pos::Span;
use errors::DiagnosticBuilder;
use std::slice;
use std::vec::IntoIter;
use syntax::ast::{self, CrateNum, Name, NodeId};
-use syntax::attr::{self, AttrMetaMethods};
+use syntax::attr;
use syntax::parse::token::InternedString;
use syntax_pos::{DUMMY_SP, Span};
use std::mem;
use std::rc::Rc;
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
use syntax_pos::{Span, DUMMY_SP};
#[derive(PartialEq, Eq, PartialOrd, Ord)]
use borrowck::BorrowckCtxt;
use syntax::ast::{self, MetaItem};
-use syntax::attr::AttrMetaMethods;
use syntax::ptr::P;
use syntax_pos::{Span, DUMMY_SP};
bd: BD) -> DataflowResults<BD>
where BD: BitDenotation<Idx=MovePathIndex, Ctxt=MoveDataParamEnv<'tcx>> + DataflowOperator
{
- use syntax::attr::AttrMetaMethods;
-
let name_found = |sess: &Session, attrs: &[ast::Attribute], name| -> Option<String> {
if let Some(item) = has_rustc_mir_with(attrs, name) {
if let Some(s) = item.value_str() {
use std::mem;
use std::rc::Rc;
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
use syntax_pos::{MultiSpan, Span};
use errors::DiagnosticBuilder;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use syntax::{ast, diagnostics, visit};
-use syntax::attr::{self, AttrMetaMethods};
+use syntax::attr;
use syntax::parse::{self, PResult, token};
use syntax::util::node_count::NodeCounter;
use syntax;
use rustc::session::early_error;
use syntax::{ast, json};
-use syntax::attr::AttrMetaMethods;
use syntax::codemap::{CodeMap, FileLoader, RealFileLoader};
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
use syntax::parse::{self, PResult};
use std::fs::File;
use std::io::Write;
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
use syntax::parse::token::InternedString;
use syntax_pos::Span;
use rustc::hir::intravisit::Visitor;
use rustc_data_structures::fnv::FnvHashSet;
use syntax::ast::{self, Attribute, NestedMetaItem};
-use syntax::attr::AttrMetaMethods;
use syntax::parse::token::InternedString;
use rustc::ty::TyCtxt;
use lint::{LintPass, LateLintPass};
use syntax::ast;
-use syntax::attr::{self, AttrMetaMethods};
+use syntax::attr;
use syntax_pos::Span;
use rustc::hir::{self, PatKind};
use std::collections::HashSet;
use syntax::{ast};
-use syntax::attr::{self, AttrMetaMethods};
+use syntax::attr;
use syntax_pos::{Span};
use rustc::hir::{self, PatKind};
impl LateLintPass for UnstableFeatures {
fn check_attribute(&mut self, ctx: &LateContext, attr: &ast::Attribute) {
- if attr::contains_name(&[attr.meta().clone()], "feature") {
+ if attr.meta().check_name("feature") {
if let Some(items) = attr.meta().meta_item_list() {
for item in items {
ctx.span_lint(UNSTABLE_FEATURES, item.span(), "unstable feature");
use std::collections::hash_map::Entry::{Occupied, Vacant};
use syntax::ast;
-use syntax::attr::{self, AttrMetaMethods};
+use syntax::attr;
use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType};
use syntax::ptr::P;
use syntax_pos::Span;
use syntax::abi::Abi;
use syntax::codemap;
use syntax::parse;
-use syntax::attr::{self, AttrMetaMethods};
+use syntax::attr;
use syntax::parse::token::InternedString;
use syntax::visit;
use syntax_pos::{self, Span, mk_sp, Pos};
use std::collections::{HashSet, HashMap};
use syntax::parse::token;
use syntax::ast;
-use syntax::attr::{self, AttrMetaMethods};
+use syntax::attr;
use syntax::ext;
use syntax_pos::Span;
use syntax::parse::token;
use rustc::hir;
use rustc_const_math::{ConstInt, ConstUsize};
-use syntax::attr::AttrMetaMethods;
#[derive(Copy, Clone)]
pub struct Cx<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
use std::mem;
use std::path::PathBuf;
use syntax::ast;
-use syntax::attr::{AttrMetaMethods};
use syntax_pos::{Span, COMMAND_LINE_SP};
/// Pointer to a registrar function.
use rustc::ty::TyCtxt;
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
use syntax::parse::token::InternedString;
use {ModuleSource, ModuleTranslation};
use std::str;
use flate;
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
use syntax_pos::Span;
// RLIB LLVM-BYTECODE OBJECT LAYOUT
use std::str;
use std::i32;
use syntax_pos::{Span, DUMMY_SP};
-use syntax::attr::AttrMetaMethods;
use syntax::attr;
use rustc::hir;
use syntax::ast;
use std::ffi::{CStr, CString};
use syntax::ast;
-use syntax::attr::{self, AttrMetaMethods};
+use syntax::attr;
use syntax::parse::token;
pub fn ptrcast(val: ValueRef, ty: Type) -> ValueRef {
use rustc::hir;
use rustc::hir::intravisit::{self, Visitor};
use syntax::ast;
-use syntax::attr::AttrMetaMethods;
use common::SharedCrateContext;
use monomorphize::Instance;
use syntax::abi::Abi;
use syntax::ast;
use syntax::attr;
-use syntax::attr::AttrMetaMethods;
use syntax::codemap::{self, Spanned};
use syntax::feature_gate::{GateIssue, emit_feature_err};
use syntax::parse::token::{self, InternedString, keywords};
use syntax::abi::Abi;
use syntax::ast;
use syntax::attr;
-use syntax::attr::AttrMetaMethods;
use syntax::codemap::Spanned;
-use syntax::parse::token::{self, InternedString, keywords};
+use syntax::parse::token::keywords;
use syntax::ptr::P;
use syntax::print::pprust as syntax_pprust;
use syntax_pos::{self, DUMMY_SP, Pos};
}
}
-// This is a rough approximation that gets us what we want.
-impl Attribute {
- fn check_name(&self, name: &str) -> bool {
- self.name().map_or(false, |mi_name| &*mi_name == name)
- }
-
- fn literal(&self) -> Option<&ast::Lit> { None }
-
- fn is_literal(&self) -> bool {
- match *self {
- Literal(..) => true,
- _ => false,
- }
- }
-
- fn meta_item(&self) -> Option<&P<ast::MetaItem>> { None }
-
- fn name(&self) -> Option<InternedString> {
- match *self {
- Word(ref n) | List(ref n, _) | NameValue(ref n, _) => {
- Some(token::intern_and_get_ident(n))
- },
- _ => None
- }
- }
-
- fn value_str(&self) -> Option<InternedString> {
- match *self {
- NameValue(_, ref v) => {
- Some(token::intern_and_get_ident(v))
- }
- _ => None,
- }
- }
-
- fn word(&self) -> Option<&P<ast::MetaItem>> { None }
-
- fn is_word(&self) -> bool {
- match *self {
- Word(_) => true,
- _ => false,
- }
- }
-
- fn meta_item_list<'a>(&'a self) -> Option<&'a [ast::NestedMetaItem]> { None }
-
- fn is_meta_item_list(&self) -> bool {
- match *self {
- List(..) => true,
- _ => false,
- }
- }
-
- fn span(&self) -> syntax_pos::Span { unimplemented!() }
-}
-
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)]
pub struct TyParam {
pub name: String,
// Look for #![doc(test(no_crate_inject))], used by crates in the std facade
fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions {
- use syntax::attr::AttrMetaMethods;
use syntax::print::pprust;
let mut opts = TestOptions {
use syntax::abi;
use syntax::ast;
use syntax::attr;
-use syntax::attr::AttrMetaMethods;
use syntax_pos::Span;
use rustc::hir::map as hir_map;
}
}
-pub trait AttrMetaMethods {
- fn check_name(&self, name: &str) -> bool {
- name == &self.name()[..]
- }
-
- /// Retrieve the name of the meta item, e.g. `foo` in `#[foo]`,
- /// `#[foo="bar"]` and `#[foo(bar)]`
- fn name(&self) -> InternedString;
-
- /// Gets the string value if self is a MetaItemKind::NameValue variant
- /// containing a string, otherwise None.
- fn value_str(&self) -> Option<InternedString>;
-
- /// Gets a list of inner meta items from a list MetaItem type.
- fn meta_item_list(&self) -> Option<&[NestedMetaItem]>;
-
- /// Indicates if the attribute is a Word.
- fn is_word(&self) -> bool;
-
- /// Indicates if the attribute is a Value String.
- fn is_value_str(&self) -> bool {
- self.value_str().is_some()
- }
-
- /// Indicates if the attribute is a Meta-Item List.
- fn is_meta_item_list(&self) -> bool {
- self.meta_item_list().is_some()
- }
-
- fn span(&self) -> Span;
-}
-
-impl AttrMetaMethods for Attribute {
- fn check_name(&self, name: &str) -> bool {
+impl Attribute {
+ pub fn check_name(&self, name: &str) -> bool {
let matches = name == &self.name()[..];
if matches {
mark_used(self);
matches
}
- fn name(&self) -> InternedString { self.meta().name() }
+ pub fn name(&self) -> InternedString { self.meta().name() }
- fn value_str(&self) -> Option<InternedString> {
+ pub fn value_str(&self) -> Option<InternedString> {
self.meta().value_str()
}
- fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
+ pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
self.meta().meta_item_list()
}
- fn is_word(&self) -> bool { self.meta().is_word() }
+ pub fn is_word(&self) -> bool { self.meta().is_word() }
+
+ pub fn span(&self) -> Span { self.meta().span }
- fn span(&self) -> Span { self.meta().span }
+ pub fn is_meta_item_list(&self) -> bool {
+ self.meta_item_list().is_some()
+ }
+
+ /// Indicates if the attribute is a Value String.
+ pub fn is_value_str(&self) -> bool {
+ self.value_str().is_some()
+ }
}
-impl AttrMetaMethods for MetaItem {
- fn name(&self) -> InternedString {
+impl MetaItem {
+ pub fn name(&self) -> InternedString {
match self.node {
MetaItemKind::Word(ref n) => (*n).clone(),
MetaItemKind::NameValue(ref n, _) => (*n).clone(),
}
}
- fn value_str(&self) -> Option<InternedString> {
+ pub fn value_str(&self) -> Option<InternedString> {
match self.node {
MetaItemKind::NameValue(_, ref v) => {
match v.node {
}
}
- fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
+ pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
match self.node {
MetaItemKind::List(_, ref l) => Some(&l[..]),
_ => None
}
}
- fn is_word(&self) -> bool {
+ pub fn is_word(&self) -> bool {
match self.node {
MetaItemKind::Word(_) => true,
_ => false,
}
}
- fn span(&self) -> Span { self.span }
-}
+ pub fn span(&self) -> Span { self.span }
+
+ pub fn check_name(&self, name: &str) -> bool {
+ name == &self.name()[..]
+ }
-// Annoying, but required to get test_cfg to work
-impl AttrMetaMethods for P<MetaItem> {
- fn name(&self) -> InternedString { (**self).name() }
- fn value_str(&self) -> Option<InternedString> { (**self).value_str() }
- fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
- (**self).meta_item_list()
+ pub fn is_value_str(&self) -> bool {
+ self.value_str().is_some()
+ }
+
+ pub fn is_meta_item_list(&self) -> bool {
+ self.meta_item_list().is_some()
}
- fn is_word(&self) -> bool { (**self).is_word() }
- fn is_value_str(&self) -> bool { (**self).is_value_str() }
- fn is_meta_item_list(&self) -> bool { (**self).is_meta_item_list() }
- fn span(&self) -> Span { (**self).span() }
}
impl Attribute {
})
}
-pub fn contains_name<AM: AttrMetaMethods>(metas: &[AM], name: &str) -> bool {
+pub fn contains_name(attrs: &[Attribute], name: &str) -> bool {
debug!("attr::contains_name (name={})", name);
- metas.iter().any(|item| {
+ attrs.iter().any(|item| {
debug!(" testing: {}", item.name());
item.check_name(name)
})
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use attr::{AttrMetaMethods, HasAttrs};
+use attr::HasAttrs;
use feature_gate::{emit_feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features, GateIssue};
use fold::Folder;
use {fold, attr};
use ast;
use ext::hygiene::Mark;
use attr::{self, HasAttrs};
-use attr::AttrMetaMethods;
use codemap::{dummy_spanned, ExpnInfo, NameAndSpan, MacroBang, MacroAttribute};
use syntax_pos::{self, Span, ExpnId};
use config::StripUnconfigured;
use abi::Abi;
use ast::{self, NodeId, PatKind};
-use attr::{self, AttrMetaMethods};
+use attr;
use codemap::CodeMap;
use syntax_pos::Span;
use errors::Handler;
use codemap::Spanned;
use ast::{self, PatKind};
use abi::Abi;
- use attr::{first_attr_value_str_by_name, AttrMetaMethods};
+ use attr::first_attr_value_str_by_name;
use parse;
use parse::parser::Parser;
use parse::token::{str_to_ident};
use ast::Attribute;
use util::parser::AssocOp;
use attr;
-use attr::AttrMetaMethods;
use codemap::{self, CodeMap};
use syntax_pos::{self, BytePos};
use errors;
use std::slice;
use std::mem;
use std::vec;
-use attr::{self, AttrMetaMethods};
+use attr;
use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, FileMap, BytePos};
use std::rc::Rc;
use syntax::abi::Abi;
use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind, VariantData};
use syntax::attr;
-use syntax::attr::AttrMetaMethods;
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax::ext::build::AstBuilder;
use syntax::codemap::{self, respan};
//! The compiler code necessary to implement the `#[derive]` extensions.
use syntax::ast::{self, MetaItem};
-use syntax::attr::AttrMetaMethods;
use syntax::ext::base::{Annotatable, ExtCtxt, SyntaxEnv};
use syntax::ext::base::{MultiDecorator, MultiItemDecorator, MultiModifier};
use syntax::ext::build::AstBuilder;