From 4eb08bb2ab43f0ad80071469771381a4dd03603d Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Tue, 23 Aug 2016 03:21:17 +0000 Subject: [PATCH 1/4] Refactor away `AttrNestedMetaItemMethods`. --- src/librustc/hir/check_attr.rs | 2 +- src/librustc/lint/context.rs | 2 +- src/librustc_borrowck/borrowck/mir/mod.rs | 2 +- src/librustc_incremental/assert_dep_graph.rs | 2 +- .../persist/dirty_clean.rs | 2 +- src/librustc_lint/builtin.rs | 2 +- src/librustc_metadata/creader.rs | 2 +- src/librustc_metadata/macro_import.rs | 2 +- src/librustc_plugin/load.rs | 2 +- src/librustc_trans/assert_module_sources.rs | 2 +- src/librustdoc/clean/mod.rs | 4 +- src/librustdoc/test.rs | 1 - src/librustdoc/visit_ast.rs | 2 +- src/libsyntax/attr.rs | 74 +++++++++---------- src/libsyntax/config.rs | 2 +- src/libsyntax/feature_gate.rs | 2 +- src/libsyntax/test.rs | 2 +- src/libsyntax_ext/deriving/mod.rs | 2 +- 18 files changed, 50 insertions(+), 59 deletions(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 350b9fd88f6..42f293577b3 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -11,7 +11,7 @@ use session::Session; use syntax::ast; -use syntax::attr::{AttrNestedMetaItemMethods, AttrMetaMethods}; +use syntax::attr::AttrMetaMethods; use syntax::visit; use syntax::visit::Visitor; diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index bccd217352b..ed812471594 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -38,7 +38,7 @@ use util::nodemap::FnvHashMap; use std::cmp; use std::default::Default as StdDefault; use std::mem; -use syntax::attr::{self, AttrMetaMethods, AttrNestedMetaItemMethods}; +use syntax::attr::{self, AttrMetaMethods}; use syntax::parse::token::InternedString; use syntax::ast; use syntax_pos::Span; diff --git a/src/librustc_borrowck/borrowck/mir/mod.rs b/src/librustc_borrowck/borrowck/mir/mod.rs index 55c6a4de9df..3285cecb79c 100644 --- a/src/librustc_borrowck/borrowck/mir/mod.rs +++ b/src/librustc_borrowck/borrowck/mir/mod.rs @@ -11,7 +11,7 @@ use borrowck::BorrowckCtxt; use syntax::ast::{self, MetaItem}; -use syntax::attr::{AttrMetaMethods, AttrNestedMetaItemMethods}; +use syntax::attr::AttrMetaMethods; use syntax::ptr::P; use syntax_pos::{Span, DUMMY_SP}; diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 482b351481c..7ab61d494b5 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -56,7 +56,7 @@ use std::env; use std::fs::File; use std::io::Write; use syntax::ast; -use syntax::attr::{AttrNestedMetaItemMethods, AttrMetaMethods}; +use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use syntax_pos::Span; diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index f0092ce04d1..0a87c083318 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -32,7 +32,7 @@ use rustc::hir::def_id::DefId; use rustc::hir::intravisit::Visitor; use rustc_data_structures::fnv::FnvHashSet; use syntax::ast::{self, Attribute, NestedMetaItem}; -use syntax::attr::{AttrNestedMetaItemMethods, AttrMetaMethods}; +use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use rustc::ty::TyCtxt; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 9a4eec2d05b..57afcc47d67 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -44,7 +44,7 @@ use lint::{LintPass, LateLintPass}; use std::collections::HashSet; use syntax::{ast}; -use syntax::attr::{self, AttrMetaMethods, AttrNestedMetaItemMethods, AttributeMethods}; +use syntax::attr::{self, AttrMetaMethods, AttributeMethods}; use syntax_pos::{Span}; use rustc::hir::{self, PatKind}; diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 4dc3d04c4a2..91b7acff03f 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -35,7 +35,7 @@ use syntax::ast; use syntax::abi::Abi; use syntax::codemap; use syntax::parse; -use syntax::attr::{self, AttrMetaMethods, AttrNestedMetaItemMethods}; +use syntax::attr::{self, AttrMetaMethods}; use syntax::parse::token::InternedString; use syntax::visit; use syntax_pos::{self, Span, mk_sp, Pos}; diff --git a/src/librustc_metadata/macro_import.rs b/src/librustc_metadata/macro_import.rs index ec0c9f455cd..2482a53fe48 100644 --- a/src/librustc_metadata/macro_import.rs +++ b/src/librustc_metadata/macro_import.rs @@ -18,7 +18,7 @@ use rustc::session::Session; use std::collections::{HashSet, HashMap}; use syntax::parse::token; use syntax::ast; -use syntax::attr::{self, AttrNestedMetaItemMethods, AttrMetaMethods}; +use syntax::attr::{self, AttrMetaMethods}; use syntax::ext; use syntax_pos::Span; diff --git a/src/librustc_plugin/load.rs b/src/librustc_plugin/load.rs index 5a8d2e58c55..895645a76cb 100644 --- a/src/librustc_plugin/load.rs +++ b/src/librustc_plugin/load.rs @@ -20,7 +20,7 @@ use std::env; use std::mem; use std::path::PathBuf; use syntax::ast; -use syntax::attr::{AttrMetaMethods, AttrNestedMetaItemMethods}; +use syntax::attr::{AttrMetaMethods}; use syntax_pos::{Span, COMMAND_LINE_SP}; /// Pointer to a registrar function. diff --git a/src/librustc_trans/assert_module_sources.rs b/src/librustc_trans/assert_module_sources.rs index e2633c82976..e0532e7476f 100644 --- a/src/librustc_trans/assert_module_sources.rs +++ b/src/librustc_trans/assert_module_sources.rs @@ -29,7 +29,7 @@ use rustc::ty::TyCtxt; use syntax::ast; -use syntax::attr::{AttrMetaMethods, AttrNestedMetaItemMethods}; +use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use {ModuleSource, ModuleTranslation}; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 02fa073dd55..79c0bfaaa34 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -26,7 +26,7 @@ pub use self::Visibility::*; use syntax::abi::Abi; use syntax::ast; use syntax::attr; -use syntax::attr::{AttributeMethods, AttrMetaMethods, AttrNestedMetaItemMethods}; +use syntax::attr::{AttributeMethods, AttrMetaMethods}; use syntax::codemap::Spanned; use syntax::parse::token::{self, InternedString, keywords}; use syntax::ptr::P; @@ -542,7 +542,7 @@ impl Clean for ast::Attribute { } // This is a rough approximation that gets us what we want. -impl attr::AttrNestedMetaItemMethods for Attribute { +impl Attribute { fn check_name(&self, name: &str) -> bool { self.name().map_or(false, |mi_name| &*mi_name == name) } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 23a047f922f..caf05a947d3 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -141,7 +141,6 @@ pub fn run(input: &str, // 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::attr::AttrNestedMetaItemMethods; use syntax::print::pprust; let mut opts = TestOptions { diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 4e3a81b1bae..d3397a04b3a 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -17,7 +17,7 @@ use std::mem; use syntax::abi; use syntax::ast; use syntax::attr; -use syntax::attr::{AttrMetaMethods, AttrNestedMetaItemMethods}; +use syntax::attr::AttrMetaMethods; use syntax_pos::Span; use rustc::hir::map as hir_map; diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 4897425f2c0..f1a820ce1d4 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -81,32 +81,47 @@ pub fn is_used(attr: &Attribute) -> bool { }) } -pub trait AttrNestedMetaItemMethods { +impl NestedMetaItem { + /// Returns the MetaItem if self is a NestedMetaItemKind::MetaItem. + pub fn meta_item(&self) -> Option<&P> { + match self.node { + NestedMetaItemKind::MetaItem(ref item) => Some(&item), + _ => None + } + } + + /// Returns the Lit if self is a NestedMetaItemKind::Literal. + pub fn literal(&self) -> Option<&Lit> { + match self.node { + NestedMetaItemKind::Literal(ref lit) => Some(&lit), + _ => None + } + } + + /// Returns the Span for `self`. + pub fn span(&self) -> Span { + self.span + } + /// Returns true if this list item is a MetaItem with a name of `name`. - fn check_name(&self, name: &str) -> bool { + pub fn check_name(&self, name: &str) -> bool { self.meta_item().map_or(false, |meta_item| meta_item.check_name(name)) } /// Returns the name of the meta item, e.g. `foo` in `#[foo]`, /// `#[foo="bar"]` and `#[foo(bar)]`, if self is a MetaItem - fn name(&self) -> Option { + pub fn name(&self) -> Option { self.meta_item().and_then(|meta_item| Some(meta_item.name())) } - /// Returns the MetaItem if self is a NestedMetaItemKind::MetaItem. - fn meta_item(&self) -> Option<&P>; - - /// Returns the Lit if self is a NestedMetaItemKind::Literal. - fn literal(&self) -> Option<&Lit>; - /// Gets the string value if self is a MetaItem and the MetaItem is a /// MetaItemKind::NameValue variant containing a string, otherwise None. - fn value_str(&self) -> Option { + pub fn value_str(&self) -> Option { self.meta_item().and_then(|meta_item| meta_item.value_str()) } /// Returns a MetaItem if self is a MetaItem with Kind Word. - fn word(&self) -> Option<&P> { + pub fn word(&self) -> Option<&P> { self.meta_item().and_then(|meta_item| if meta_item.is_word() { Some(meta_item) } else { @@ -115,57 +130,34 @@ pub trait AttrNestedMetaItemMethods { } /// Gets a list of inner meta items from a list MetaItem type. - fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { + pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { self.meta_item().and_then(|meta_item| meta_item.meta_item_list()) } /// Returns `true` if the variant is MetaItem. - fn is_meta_item(&self) -> bool { + pub fn is_meta_item(&self) -> bool { self.meta_item().is_some() } /// Returns `true` if the variant is Literal. - fn is_literal(&self) -> bool { + pub fn is_literal(&self) -> bool { self.literal().is_some() } /// Returns `true` if self is a MetaItem and the meta item is a word. - fn is_word(&self) -> bool { + pub fn is_word(&self) -> bool { self.word().is_some() } /// Returns `true` if self is a MetaItem and the meta item is a ValueString. - fn is_value_str(&self) -> bool { + pub fn is_value_str(&self) -> bool { self.value_str().is_some() } /// Returns `true` if self is a MetaItem and the meta item is a list. - fn is_meta_item_list(&self) -> bool { + pub fn is_meta_item_list(&self) -> bool { self.meta_item_list().is_some() } - - /// Returns the Span for `self`. - fn span(&self) -> Span; -} - -impl AttrNestedMetaItemMethods for NestedMetaItem { - fn meta_item(&self) -> Option<&P> { - match self.node { - NestedMetaItemKind::MetaItem(ref item) => Some(&item), - _ => None - } - } - - fn literal(&self) -> Option<&Lit> { - match self.node { - NestedMetaItemKind::Literal(ref lit) => Some(&lit), - _ => None - } - } - - fn span(&self) -> Span { - self.span - } } pub trait AttrMetaMethods { @@ -431,7 +423,7 @@ pub fn contains(haystack: &[P], needle: &MetaItem) -> bool { }) } -pub fn list_contains_name(items: &[AM], name: &str) -> bool { +pub fn list_contains_name(items: &[NestedMetaItem], name: &str) -> bool { debug!("attr::list_contains_name (name={})", name); items.iter().any(|item| { debug!(" testing: {:?}", item.name()); diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 4663143f4b1..ed05dc243b3 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use attr::{AttrMetaMethods, AttrNestedMetaItemMethods, HasAttrs}; +use attr::{AttrMetaMethods, HasAttrs}; use feature_gate::{emit_feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features, GateIssue}; use fold::Folder; use {fold, attr}; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index df1d5c4d9ca..d2aa9a4cb6b 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -27,7 +27,7 @@ use self::AttributeGate::*; use abi::Abi; use ast::{self, NodeId, PatKind}; -use attr::{self, AttrMetaMethods, AttrNestedMetaItemMethods}; +use attr::{self, AttrMetaMethods}; use codemap::CodeMap; use syntax_pos::Span; use errors::Handler; diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index ce917f248e1..0a14eae7d35 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -19,7 +19,7 @@ use std::iter; use std::slice; use std::mem; use std::vec; -use attr::{self, AttrMetaMethods, AttrNestedMetaItemMethods}; +use attr::{self, AttrMetaMethods}; use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, FileMap, BytePos}; use std::rc::Rc; diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index ffc1bfd6db8..fae17c0465b 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -11,7 +11,7 @@ //! The compiler code necessary to implement the `#[derive]` extensions. use syntax::ast::{self, MetaItem}; -use syntax::attr::{AttrNestedMetaItemMethods, AttrMetaMethods}; +use syntax::attr::AttrMetaMethods; use syntax::ext::base::{Annotatable, ExtCtxt, SyntaxEnv}; use syntax::ext::base::{MultiDecorator, MultiItemDecorator, MultiModifier}; use syntax::ext::build::AstBuilder; From e264828b27b30980f6a9c316e17dc44e6b9be09f Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Tue, 23 Aug 2016 03:39:04 +0000 Subject: [PATCH 2/4] Refactor away `AttributeMethods`. --- src/librustc/traits/error_reporting.rs | 2 +- src/librustc_incremental/calculate_svh/mod.rs | 1 - src/librustc_lint/builtin.rs | 2 +- src/librustdoc/clean/mod.rs | 2 +- src/libsyntax/attr.rs | 13 +++---------- src/libsyntax/print/pprust.rs | 2 +- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index d6f263fcebe..b8c5ed51eab 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -37,7 +37,7 @@ use util::nodemap::{FnvHashMap, FnvHashSet}; use std::cmp; use std::fmt; use syntax::ast; -use syntax::attr::{AttributeMethods, AttrMetaMethods}; +use syntax::attr::AttrMetaMethods; use syntax_pos::Span; use errors::DiagnosticBuilder; diff --git a/src/librustc_incremental/calculate_svh/mod.rs b/src/librustc_incremental/calculate_svh/mod.rs index 42bb1a52467..b14c20ae8d4 100644 --- a/src/librustc_incremental/calculate_svh/mod.rs +++ b/src/librustc_incremental/calculate_svh/mod.rs @@ -28,7 +28,6 @@ //! at the beginning. use syntax::ast; -use syntax::attr::AttributeMethods; use std::hash::{Hash, SipHasher, Hasher}; use rustc::dep_graph::DepNode; use rustc::hir; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 57afcc47d67..6ab53b75f50 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -44,7 +44,7 @@ use lint::{LintPass, LateLintPass}; use std::collections::HashSet; use syntax::{ast}; -use syntax::attr::{self, AttrMetaMethods, AttributeMethods}; +use syntax::attr::{self, AttrMetaMethods}; use syntax_pos::{Span}; use rustc::hir::{self, PatKind}; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 79c0bfaaa34..1f1844f9b73 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -26,7 +26,7 @@ pub use self::Visibility::*; use syntax::abi::Abi; use syntax::ast; use syntax::attr; -use syntax::attr::{AttributeMethods, AttrMetaMethods}; +use syntax::attr::AttrMetaMethods; use syntax::codemap::Spanned; use syntax::parse::token::{self, InternedString, keywords}; use syntax::ptr::P; diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index f1a820ce1d4..f8fecd5fda0 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -267,23 +267,16 @@ impl AttrMetaMethods for P { fn span(&self) -> Span { (**self).span() } } - -pub trait AttributeMethods { - fn meta(&self) -> &MetaItem; - fn with_desugared_doc(&self, f: F) -> T where - F: FnOnce(&Attribute) -> T; -} - -impl AttributeMethods for Attribute { +impl Attribute { /// Extract the MetaItem from inside this Attribute. - fn meta(&self) -> &MetaItem { + pub fn meta(&self) -> &MetaItem { &self.node.value } /// Convert self to a normal #[doc="foo"] comment, if it is a /// comment like `///` or `/** */`. (Returns self unchanged for /// non-sugared doc attributes.) - fn with_desugared_doc(&self, f: F) -> T where + pub fn with_desugared_doc(&self, f: F) -> T where F: FnOnce(&Attribute) -> T, { if self.node.is_sugared_doc { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 562cc896aef..0caf9ae0d78 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -16,7 +16,7 @@ use ast::{SelfKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::Attribute; use util::parser::AssocOp; use attr; -use attr::{AttrMetaMethods, AttributeMethods}; +use attr::AttrMetaMethods; use codemap::{self, CodeMap}; use syntax_pos::{self, BytePos}; use errors; From bfb01bbb263923106b33fdaa140a5fa464426162 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Tue, 23 Aug 2016 03:54:53 +0000 Subject: [PATCH 3/4] Refactor away `AttrMetaMethods`. --- src/librustc/hir/check_attr.rs | 1 - src/librustc/lint/context.rs | 2 +- src/librustc/middle/lang_items.rs | 1 - src/librustc/middle/recursion_limit.rs | 1 - src/librustc/middle/stability.rs | 2 +- src/librustc/session/config.rs | 2 - src/librustc/traits/error_reporting.rs | 1 - src/librustc/ty/mod.rs | 2 +- src/librustc_borrowck/borrowck/fragments.rs | 1 - src/librustc_borrowck/borrowck/mir/mod.rs | 3 - src/librustc_borrowck/borrowck/mod.rs | 1 - src/librustc_driver/driver.rs | 2 +- src/librustc_driver/lib.rs | 1 - src/librustc_incremental/assert_dep_graph.rs | 1 - .../persist/dirty_clean.rs | 1 - src/librustc_lint/bad_style.rs | 2 +- src/librustc_lint/builtin.rs | 4 +- src/librustc_lint/unused.rs | 2 +- src/librustc_metadata/creader.rs | 2 +- src/librustc_metadata/macro_import.rs | 2 +- src/librustc_mir/hair/cx/mod.rs | 1 - src/librustc_plugin/load.rs | 1 - src/librustc_trans/assert_module_sources.rs | 1 - src/librustc_trans/back/link.rs | 1 - src/librustc_trans/base.rs | 1 - src/librustc_trans/consts.rs | 2 +- src/librustc_trans/symbol_names_test.rs | 1 - src/librustc_typeck/check/mod.rs | 1 - src/librustdoc/clean/mod.rs | 59 +----------- src/librustdoc/test.rs | 1 - src/librustdoc/visit_ast.rs | 1 - src/libsyntax/attr.rs | 92 +++++++------------ src/libsyntax/config.rs | 2 +- src/libsyntax/ext/expand.rs | 1 - src/libsyntax/feature_gate.rs | 2 +- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/print/pprust.rs | 1 - src/libsyntax/test.rs | 2 +- src/libsyntax_ext/deriving/generic/mod.rs | 1 - src/libsyntax_ext/deriving/mod.rs | 1 - 40 files changed, 50 insertions(+), 158 deletions(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 42f293577b3..21143f93a7d 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -11,7 +11,6 @@ use session::Session; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax::visit; use syntax::visit::Visitor; diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index ed812471594..c9211586143 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -38,7 +38,7 @@ use util::nodemap::FnvHashMap; 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; diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index a209b1d1abd..d1769d5cbc5 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -30,7 +30,6 @@ use middle::weak_lang_items; use util::nodemap::FnvHashMap; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use hir::intravisit::Visitor; use hir; diff --git a/src/librustc/middle/recursion_limit.rs b/src/librustc/middle/recursion_limit.rs index 7dcd358165c..0764e817f43 100644 --- a/src/librustc/middle/recursion_limit.rs +++ b/src/librustc/middle/recursion_limit.rs @@ -17,7 +17,6 @@ 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 { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index cbbc2c4f98f..405202bc634 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -27,7 +27,7 @@ use syntax_pos::{Span, DUMMY_SP}; 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; diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 8a32797dbd7..7a1848f42d2 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -25,7 +25,6 @@ use middle::cstore; 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; @@ -1774,7 +1773,6 @@ mod tests { use std::rc::Rc; use super::{OutputType, OutputTypes, Externs, PanicStrategy}; use syntax::attr; - use syntax::attr::AttrMetaMethods; fn optgroups() -> Vec { super::rustc_optgroups().into_iter() diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index b8c5ed51eab..a09ce38c4bb 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -37,7 +37,6 @@ use util::nodemap::{FnvHashMap, FnvHashSet}; use std::cmp; use std::fmt; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax_pos::Span; use errors::DiagnosticBuilder; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 6c82157c8ca..ded9867fa6f 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -43,7 +43,7 @@ use std::rc::Rc; 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}; diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index d3d6fa9eb52..a8993724e67 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -27,7 +27,6 @@ use rustc::middle::mem_categorization as mc; 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)] diff --git a/src/librustc_borrowck/borrowck/mir/mod.rs b/src/librustc_borrowck/borrowck/mir/mod.rs index 3285cecb79c..2d429aaab6a 100644 --- a/src/librustc_borrowck/borrowck/mir/mod.rs +++ b/src/librustc_borrowck/borrowck/mir/mod.rs @@ -11,7 +11,6 @@ use borrowck::BorrowckCtxt; use syntax::ast::{self, MetaItem}; -use syntax::attr::AttrMetaMethods; use syntax::ptr::P; use syntax_pos::{Span, DUMMY_SP}; @@ -127,8 +126,6 @@ fn do_dataflow<'a, 'tcx, BD>(tcx: TyCtxt<'a, 'tcx, 'tcx>, bd: BD) -> DataflowResults where BD: BitDenotation> + DataflowOperator { - use syntax::attr::AttrMetaMethods; - let name_found = |sess: &Session, attrs: &[ast::Attribute], name| -> Option { if let Some(item) = has_rustc_mir_with(attrs, name) { if let Some(s) = item.value_str() { diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 225895adefa..343e9251e1d 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -42,7 +42,6 @@ use std::fmt; use std::mem; use std::rc::Rc; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax_pos::{MultiSpan, Span}; use errors::DiagnosticBuilder; diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 3f2f6c84da1..c6ab4578f06 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -49,7 +49,7 @@ use std::fs; 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; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 1f3f823d0b8..efadf1ff488 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -95,7 +95,6 @@ use std::thread; 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}; diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 7ab61d494b5..8df8f500371 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -56,7 +56,6 @@ use std::env; use std::fs::File; use std::io::Write; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use syntax_pos::Span; diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 0a87c083318..fda7ef207a3 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -32,7 +32,6 @@ use rustc::hir::def_id::DefId; 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; diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index 15914838acf..0e130c3bb66 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -14,7 +14,7 @@ use lint::{LateContext, LintContext, LintArray}; use lint::{LintPass, LateLintPass}; use syntax::ast; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax_pos::Span; use rustc::hir::{self, PatKind}; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 6ab53b75f50..a103386e2c9 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -44,7 +44,7 @@ use lint::{LintPass, LateLintPass}; use std::collections::HashSet; use syntax::{ast}; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax_pos::{Span}; use rustc::hir::{self, PatKind}; @@ -1145,7 +1145,7 @@ impl LintPass for UnstableFeatures { 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"); diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 44c2ffe45cc..411daa0c12a 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -18,7 +18,7 @@ use lint::{LintPass, EarlyLintPass, LateLintPass}; 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; diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 91b7acff03f..7e1f3ea618c 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -35,7 +35,7 @@ use syntax::ast; 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}; diff --git a/src/librustc_metadata/macro_import.rs b/src/librustc_metadata/macro_import.rs index 2482a53fe48..25fedb10201 100644 --- a/src/librustc_metadata/macro_import.rs +++ b/src/librustc_metadata/macro_import.rs @@ -18,7 +18,7 @@ use rustc::session::Session; 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; diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 972e7f5be70..f65680b567c 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -32,7 +32,6 @@ use rustc::ty::{self, Ty, TyCtxt}; 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> { diff --git a/src/librustc_plugin/load.rs b/src/librustc_plugin/load.rs index 895645a76cb..9e56397bc99 100644 --- a/src/librustc_plugin/load.rs +++ b/src/librustc_plugin/load.rs @@ -20,7 +20,6 @@ use std::env; 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. diff --git a/src/librustc_trans/assert_module_sources.rs b/src/librustc_trans/assert_module_sources.rs index e0532e7476f..7fe6d2bbfe2 100644 --- a/src/librustc_trans/assert_module_sources.rs +++ b/src/librustc_trans/assert_module_sources.rs @@ -29,7 +29,6 @@ use rustc::ty::TyCtxt; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use {ModuleSource, ModuleTranslation}; diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 9f401b13d6f..b21785c27da 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -42,7 +42,6 @@ use std::process::Command; use std::str; use flate; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax_pos::Span; // RLIB LLVM-BYTECODE OBJECT LAYOUT diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 165884c8f55..f231344f22f 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -93,7 +93,6 @@ use std::rc::Rc; 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; diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index fa1e008d496..2b6e2a23261 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -29,7 +29,7 @@ use rustc::hir; 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 { diff --git a/src/librustc_trans/symbol_names_test.rs b/src/librustc_trans/symbol_names_test.rs index 9a7fe54e0d9..25c30151ad4 100644 --- a/src/librustc_trans/symbol_names_test.rs +++ b/src/librustc_trans/symbol_names_test.rs @@ -17,7 +17,6 @@ use rustc::hir; use rustc::hir::intravisit::{self, Visitor}; use syntax::ast; -use syntax::attr::AttrMetaMethods; use common::SharedCrateContext; use monomorphize::Instance; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 16300d869ab..619aafa799f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -113,7 +113,6 @@ use std::ops::Deref; 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}; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 1f1844f9b73..3a1e22f81b5 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -26,9 +26,8 @@ pub use self::Visibility::*; 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}; @@ -541,62 +540,6 @@ impl Clean for ast::Attribute { } } -// 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> { None } - - fn name(&self) -> Option { - match *self { - Word(ref n) | List(ref n, _) | NameValue(ref n, _) => { - Some(token::intern_and_get_ident(n)) - }, - _ => None - } - } - - fn value_str(&self) -> Option { - match *self { - NameValue(_, ref v) => { - Some(token::intern_and_get_ident(v)) - } - _ => None, - } - } - - fn word(&self) -> Option<&P> { 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, diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index caf05a947d3..1805da2385b 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -140,7 +140,6 @@ pub fn run(input: &str, // 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 { diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index d3397a04b3a..e66d01e5c2d 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -17,7 +17,6 @@ use std::mem; use syntax::abi; use syntax::ast; use syntax::attr; -use syntax::attr::AttrMetaMethods; use syntax_pos::Span; use rustc::hir::map as hir_map; diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index f8fecd5fda0..6060ff529f2 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -160,40 +160,8 @@ impl NestedMetaItem { } } -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; - - /// 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); @@ -201,23 +169,32 @@ impl AttrMetaMethods for Attribute { matches } - fn name(&self) -> InternedString { self.meta().name() } + pub fn name(&self) -> InternedString { self.meta().name() } - fn value_str(&self) -> Option { + pub fn value_str(&self) -> Option { 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() } - fn span(&self) -> Span { self.meta().span } + pub 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(), @@ -225,7 +202,7 @@ impl AttrMetaMethods for MetaItem { } } - fn value_str(&self) -> Option { + pub fn value_str(&self) -> Option { match self.node { MetaItemKind::NameValue(_, ref v) => { match v.node { @@ -237,34 +214,33 @@ impl AttrMetaMethods for MetaItem { } } - 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 } -// Annoying, but required to get test_cfg to work -impl AttrMetaMethods for P { - fn name(&self) -> InternedString { (**self).name() } - fn value_str(&self) -> Option { (**self).value_str() } - fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { - (**self).meta_item_list() + pub fn check_name(&self, name: &str) -> bool { + name == &self.name()[..] + } + + 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 { @@ -424,9 +400,9 @@ pub fn list_contains_name(items: &[NestedMetaItem], name: &str) -> bool { }) } -pub fn contains_name(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) }) diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index ed05dc243b3..ff1ecd44371 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -8,7 +8,7 @@ // 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}; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 031d9a2d3f4..bc0f4de4471 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -13,7 +13,6 @@ use ast::{MacStmtStyle, Stmt, StmtKind, ItemKind}; 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; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index d2aa9a4cb6b..cd2705fb7d8 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -27,7 +27,7 @@ use self::AttributeGate::*; use abi::Abi; use ast::{self, NodeId, PatKind}; -use attr::{self, AttrMetaMethods}; +use attr; use codemap::CodeMap; use syntax_pos::Span; use errors::Handler; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index cd1fdcfe9d1..6f06dd14d8f 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -678,7 +678,7 @@ mod tests { 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}; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 0caf9ae0d78..28f1016c51f 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -16,7 +16,6 @@ use ast::{SelfKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::Attribute; use util::parser::AssocOp; use attr; -use attr::AttrMetaMethods; use codemap::{self, CodeMap}; use syntax_pos::{self, BytePos}; use errors; diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 0a14eae7d35..e3e2457c471 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -19,7 +19,7 @@ use std::iter; 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; diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index bae40ddf45c..0d69fc00799 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -194,7 +194,6 @@ use std::vec; 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}; diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index fae17c0465b..81085122e87 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -11,7 +11,6 @@ //! 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; From 469753f0abc4b9eac811d8b2955d478825f9c3e1 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Wed, 24 Aug 2016 23:59:18 +0000 Subject: [PATCH 4/4] Fix fallout in tests. --- src/librustc/session/config.rs | 8 ++++++-- .../compile-fail-fulldeps/auxiliary/macro_crate_test.rs | 1 - .../auxiliary/custom_derive_plugin_attr.rs | 1 - src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs | 1 - 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 7a1848f42d2..562dce6a1b1 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1772,7 +1772,9 @@ mod tests { use std::path::PathBuf; use std::rc::Rc; use super::{OutputType, OutputTypes, Externs, PanicStrategy}; - use syntax::attr; + use syntax::{ast, attr}; + use syntax::parse::token::InternedString; + use syntax::codemap::dummy_spanned; fn optgroups() -> Vec { super::rustc_optgroups().into_iter() @@ -1801,7 +1803,9 @@ mod tests { let (sessopts, cfg) = build_session_options_and_crate_config(matches); let sess = build_session(sessopts, &dep_graph, None, registry, Rc::new(DummyCrateStore)); let cfg = build_configuration(&sess, cfg); - assert!((attr::contains_name(&cfg[..], "test"))); + assert!(attr::contains(&cfg, &dummy_spanned(ast::MetaItemKind::Word({ + InternedString::new("test") + })))); } // When the user supplies --test and --cfg test, don't implicitly add diff --git a/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs b/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs index 6db10eeae76..5a3412b7ed9 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs @@ -18,7 +18,6 @@ extern crate rustc; extern crate rustc_plugin; use syntax::ast::{self, Item, MetaItem, ItemKind}; -use syntax::attr::{AttrMetaMethods, AttrNestedMetaItemMethods}; use syntax::ext::base::*; use syntax::parse::{self, token}; use syntax::ptr::P; diff --git a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs index 882e90b2d6c..91b4b74797a 100644 --- a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs +++ b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs @@ -21,7 +21,6 @@ extern crate rustc; extern crate rustc_plugin; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax::ext::base::{MultiDecorator, ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token; diff --git a/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs b/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs index e37cd89f299..46fdf911258 100644 --- a/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs +++ b/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs @@ -19,7 +19,6 @@ extern crate syntax_pos; use syntax::ast::{self, Item, MetaItem, ItemKind}; use syntax::codemap::DUMMY_SP; -use syntax::attr::{AttrMetaMethods, AttrNestedMetaItemMethods}; use syntax::ext::base::*; use syntax::ext::quote::rt::ToTokens; use syntax::parse::{self, token};