From 93a8283614e995a0cf7a866356609b7522cfda24 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 11 Jan 2020 13:15:20 +0100 Subject: [PATCH] Move builtin attribute logic to new rustc_attr crate. For now, this is all the crate contains, but more attribute logic & types will be moved there over time. --- Cargo.lock | 31 +++++++++++++++++++ src/librustc/Cargo.toml | 1 + src/librustc/ich/impls_hir.rs | 2 +- src/librustc/middle/codegen_fn_attrs.rs | 2 +- src/librustc/middle/stability.rs | 2 +- src/librustc/mir/mono.rs | 2 +- src/librustc/traits/on_unimplemented.rs | 2 +- src/librustc/ty/context.rs | 2 +- src/librustc/ty/layout.rs | 2 +- src/librustc/ty/mod.rs | 2 +- src/librustc/ty/print/pretty.rs | 2 +- src/librustc/ty/query/mod.rs | 2 +- src/librustc/ty/util.rs | 2 +- src/librustc_ast_passes/Cargo.toml | 1 + src/librustc_ast_passes/ast_validation.rs | 2 +- src/librustc_attr/Cargo.toml | 21 +++++++++++++ .../attr => librustc_attr}/builtin.rs | 8 ++--- src/librustc_attr/lib.rs | 16 ++++++++++ src/librustc_builtin_macros/Cargo.toml | 1 + src/librustc_builtin_macros/cfg.rs | 2 +- .../deriving/generic/mod.rs | 2 +- src/librustc_codegen_llvm/Cargo.toml | 1 + src/librustc_codegen_llvm/attributes.rs | 2 +- src/librustc_codegen_ssa/Cargo.toml | 1 + src/librustc_codegen_ssa/back/link.rs | 2 +- src/librustc_codegen_ssa/base.rs | 2 +- src/librustc_expand/Cargo.toml | 1 + src/librustc_expand/base.rs | 2 +- src/librustc_expand/expand.rs | 2 +- src/librustc_expand/mbe/macro_rules.rs | 2 +- src/librustc_interface/Cargo.toml | 1 + src/librustc_interface/util.rs | 4 +-- src/librustc_lint/Cargo.toml | 1 + src/librustc_lint/nonstandard_style.rs | 2 +- src/librustc_lint/types.rs | 3 +- src/librustc_metadata/Cargo.toml | 1 + src/librustc_metadata/native_libs.rs | 2 +- src/librustc_metadata/rmeta/decoder.rs | 2 +- src/librustc_metadata/rmeta/mod.rs | 3 +- src/librustc_mir/Cargo.toml | 1 + src/librustc_mir/const_eval/fn_queries.rs | 2 +- src/librustc_mir/transform/inline.rs | 2 +- src/librustc_mir_build/Cargo.toml | 1 + .../build/matches/simplify.rs | 2 +- src/librustc_mir_build/build/mod.rs | 2 +- src/librustc_mir_build/hair/pattern/_match.rs | 2 +- src/librustc_mir_build/hair/pattern/mod.rs | 2 +- src/librustc_parse/Cargo.toml | 1 + src/librustc_parse/config.rs | 2 +- src/librustc_passes/Cargo.toml | 1 + src/librustc_passes/stability.rs | 2 +- src/librustc_privacy/Cargo.toml | 1 + src/librustc_privacy/lib.rs | 2 +- src/librustc_resolve/Cargo.toml | 1 + src/librustc_resolve/build_reduced_graph.rs | 2 +- src/librustc_resolve/macros.rs | 2 +- src/librustc_typeck/Cargo.toml | 1 + src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/collect.rs | 2 +- src/librustdoc/clean/mod.rs | 2 +- src/librustdoc/core.rs | 2 +- src/librustdoc/lib.rs | 1 + src/libsyntax/attr/mod.rs | 7 ----- 63 files changed, 133 insertions(+), 53 deletions(-) create mode 100644 src/librustc_attr/Cargo.toml rename src/{libsyntax/attr => librustc_attr}/builtin.rs (99%) create mode 100644 src/librustc_attr/lib.rs diff --git a/Cargo.lock b/Cargo.lock index c081f2fbf20..55f7a8357b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3093,6 +3093,7 @@ dependencies = [ "rustc-rayon", "rustc-rayon-core", "rustc_apfloat", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3374,6 +3375,7 @@ name = "rustc_ast_passes" version = "0.0.0" dependencies = [ "log", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3383,12 +3385,28 @@ dependencies = [ "syntax", ] +[[package]] +name = "rustc_attr" +version = "0.0.0" +dependencies = [ + "rustc_data_structures", + "rustc_errors", + "rustc_feature", + "rustc_macros", + "rustc_session", + "rustc_span", + "serialize", + "smallvec 1.0.0", + "syntax", +] + [[package]] name = "rustc_builtin_macros" version = "0.0.0" dependencies = [ "fmt_macros", "log", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_expand", @@ -3411,6 +3429,7 @@ dependencies = [ "log", "rustc", "rustc-demangle", + "rustc_attr", "rustc_codegen_ssa", "rustc_codegen_utils", "rustc_data_structures", @@ -3442,6 +3461,7 @@ dependencies = [ "num_cpus", "rustc", "rustc_apfloat", + "rustc_attr", "rustc_codegen_utils", "rustc_data_structures", "rustc_errors", @@ -3552,6 +3572,7 @@ version = "0.0.0" dependencies = [ "log", "rustc_ast_passes", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3628,6 +3649,7 @@ dependencies = [ "rustc-rayon", "rustc_ast_lowering", "rustc_ast_passes", + "rustc_attr", "rustc_builtin_macros", "rustc_codegen_llvm", "rustc_codegen_ssa", @@ -3672,6 +3694,7 @@ version = "0.0.0" dependencies = [ "log", "rustc", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3712,6 +3735,7 @@ dependencies = [ "log", "memmap", "rustc", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_expand", @@ -3739,6 +3763,7 @@ dependencies = [ "polonius-engine", "rustc", "rustc_apfloat", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -3761,6 +3786,7 @@ dependencies = [ "log", "rustc", "rustc_apfloat", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -3780,6 +3806,7 @@ version = "0.0.0" dependencies = [ "bitflags", "log", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3797,6 +3824,7 @@ version = "0.0.0" dependencies = [ "log", "rustc", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3827,6 +3855,7 @@ version = "0.0.0" dependencies = [ "log", "rustc", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -3844,6 +3873,7 @@ dependencies = [ "log", "rustc", "rustc_ast_lowering", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_expand", @@ -3961,6 +3991,7 @@ dependencies = [ "arena", "log", "rustc", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_hir", diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index b65635be54a..782c6879ac5 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -21,6 +21,7 @@ rustc-rayon = "0.3.0" rustc-rayon-core = "0.3.0" polonius-engine = "0.11.0" rustc_apfloat = { path = "../librustc_apfloat" } +rustc_attr = { path = "../librustc_attr" } rustc_feature = { path = "../librustc_feature" } rustc_hir = { path = "../librustc_hir" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 8961f7cd4bc..061b82ebb43 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -3,12 +3,12 @@ use crate::hir::map::DefPathHash; use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext}; +use rustc_attr as attr; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX}; use smallvec::SmallVec; use std::mem; -use syntax::attr; impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> { #[inline] diff --git a/src/librustc/middle/codegen_fn_attrs.rs b/src/librustc/middle/codegen_fn_attrs.rs index 3b109f2fea6..9f8c2020861 100644 --- a/src/librustc/middle/codegen_fn_attrs.rs +++ b/src/librustc/middle/codegen_fn_attrs.rs @@ -1,6 +1,6 @@ use crate::mir::mono::Linkage; +use rustc_attr::{InlineAttr, OptimizeAttr}; use rustc_span::symbol::Symbol; -use syntax::attr::{InlineAttr, OptimizeAttr}; #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub struct CodegenFnAttrs { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 1176ffc79d2..752b0945e71 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -5,6 +5,7 @@ pub use self::StabilityLevel::*; use crate::session::{DiagnosticMessageId, Session}; use crate::ty::{self, TyCtxt}; +use rustc_attr::{self as attr, ConstStability, Deprecation, RustcDeprecation, Stability}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_feature::GateIssue; @@ -16,7 +17,6 @@ use rustc_session::lint::{self, BuiltinLintDiagnostics, Lint, LintBuffer}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{MultiSpan, Span}; use syntax::ast::CRATE_NODE_ID; -use syntax::attr::{self, ConstStability, Deprecation, RustcDeprecation, Stability}; use syntax::sess::feature_err_issue; use std::num::NonZeroU32; diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index d1973266463..6da7c09c7df 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -3,6 +3,7 @@ use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext}; use crate::session::config::OptLevel; use crate::ty::print::obsolete::DefPathBasedNames; use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt}; +use rustc_attr::InlineAttr; use rustc_data_structures::base_n; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -12,7 +13,6 @@ use rustc_span::source_map::Span; use rustc_span::symbol::Symbol; use std::fmt; use std::hash::Hash; -use syntax::attr::InlineAttr; /// Describes how a monomorphization will be instantiated in object files. #[derive(PartialEq)] diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index 669ec5ccc9b..ca824d40e38 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -3,13 +3,13 @@ use fmt_macros::{Parser, Piece, Position}; use crate::ty::{self, GenericParamDefKind, TyCtxt}; use crate::util::common::ErrorReported; +use rustc_attr as attr; use rustc_data_structures::fx::FxHashMap; use rustc_errors::struct_span_err; use rustc_hir::def_id::DefId; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; use syntax::ast::{MetaItem, NestedMetaItem}; -use syntax::attr; #[derive(Clone, Debug)] pub struct OnUnimplementedFormatString(Symbol); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 355df86046f..8d0b7756565 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -51,6 +51,7 @@ use rustc_session::config::CrateType; use rustc_session::config::{BorrowckMode, OutputFilenames}; use rustc_session::Session; +use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap}; @@ -79,7 +80,6 @@ use std::mem; use std::ops::{Bound, Deref}; use std::sync::Arc; use syntax::ast; -use syntax::attr; use syntax::expand::allocator::AllocatorKind; type InternedSet<'tcx, T> = ShardedHashMap, ()>; diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index acaa4eec941..bda42db40b0 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1,9 +1,9 @@ use crate::session::{self, DataTypeKind}; use crate::ty::{self, subst::SubstsRef, ReprOptions, Ty, TyCtxt, TypeFoldable}; +use rustc_attr as attr; use rustc_span::DUMMY_SP; use syntax::ast::{self, Ident, IntTy, UintTy}; -use syntax::attr; use std::cmp; use std::fmt; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 4889f751f60..24b22d3f682 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -26,6 +26,7 @@ use crate::ty::layout::VariantIdx; use crate::ty::subst::{InternalSubsts, Subst, SubstsRef}; use crate::ty::util::{Discr, IntTypeExt}; use crate::ty::walk::TypeWalker; +use rustc_attr as attr; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxIndexMap; @@ -53,7 +54,6 @@ use std::ops::Range; use std::slice; use std::{mem, ptr}; use syntax::ast::{self, Constness, Ident, Name, NodeId}; -use syntax::attr; pub use self::sty::BoundRegion::*; pub use self::sty::InferTy::*; diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index db539f9195c..f5c14e73db2 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -11,10 +11,10 @@ use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; +use rustc_attr::{SignedInt, UnsignedInt}; use rustc_span::symbol::{kw, Symbol}; use rustc_target::spec::abi::Abi; use syntax::ast; -use syntax::attr::{SignedInt, UnsignedInt}; use std::cell::Cell; use std::collections::BTreeMap; diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 0f09a08b199..973cd810146 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -49,6 +49,7 @@ use rustc_hir::{HirIdSet, ItemLocalId, TraitCandidate}; use rustc_index::vec::IndexVec; use rustc_target::spec::PanicStrategy; +use rustc_attr as attr; use rustc_span::symbol::Symbol; use rustc_span::{Span, DUMMY_SP}; use std::any::type_name; @@ -56,7 +57,6 @@ use std::borrow::Cow; use std::ops::Deref; use std::sync::Arc; use syntax::ast; -use syntax::attr; #[macro_use] mod plumbing; diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 8d22ac9dbbe..4dfff85d531 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -10,6 +10,7 @@ use crate::ty::TyKind::*; use crate::ty::{self, DefIdTree, GenericParamDefKind, Ty, TyCtxt, TypeFoldable}; use crate::util::common::ErrorReported; use rustc_apfloat::Float as _; +use rustc_attr::{self as attr, SignedInt, UnsignedInt}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_hir as hir; @@ -19,7 +20,6 @@ use rustc_macros::HashStable; use rustc_span::Span; use std::{cmp, fmt}; use syntax::ast; -use syntax::attr::{self, SignedInt, UnsignedInt}; #[derive(Copy, Clone, Debug)] pub struct Discr<'tcx> { diff --git a/src/librustc_ast_passes/Cargo.toml b/src/librustc_ast_passes/Cargo.toml index 25b1acebd2a..2b25f04ce9a 100644 --- a/src/librustc_ast_passes/Cargo.toml +++ b/src/librustc_ast_passes/Cargo.toml @@ -10,6 +10,7 @@ path = "lib.rs" [dependencies] log = "0.4" +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_feature = { path = "../librustc_feature" } diff --git a/src/librustc_ast_passes/ast_validation.rs b/src/librustc_ast_passes/ast_validation.rs index 152086bfce0..c6ea97be583 100644 --- a/src/librustc_ast_passes/ast_validation.rs +++ b/src/librustc_ast_passes/ast_validation.rs @@ -331,7 +331,7 @@ impl<'a> AstValidator<'a> { .flat_map(|i| i.attrs.as_ref()) .filter(|attr| { let arr = [sym::allow, sym::cfg, sym::cfg_attr, sym::deny, sym::forbid, sym::warn]; - !arr.contains(&attr.name_or_empty()) && attr::is_builtin_attr(attr) + !arr.contains(&attr.name_or_empty()) && rustc_attr::is_builtin_attr(attr) }) .for_each(|attr| { if attr.is_doc_comment() { diff --git a/src/librustc_attr/Cargo.toml b/src/librustc_attr/Cargo.toml new file mode 100644 index 00000000000..acb93e1d640 --- /dev/null +++ b/src/librustc_attr/Cargo.toml @@ -0,0 +1,21 @@ +[package] +authors = ["The Rust Project Developers"] +name = "rustc_attr" +version = "0.0.0" +edition = "2018" + +[lib] +name = "rustc_attr" +path = "lib.rs" +doctest = false + +[dependencies] +rustc_serialize = { path = "../libserialize", package = "serialize" } +rustc_errors = { path = "../librustc_errors" } +rustc_span = { path = "../librustc_span" } +rustc_data_structures = { path = "../librustc_data_structures" } +rustc_feature = { path = "../librustc_feature" } +rustc_macros = { path = "../librustc_macros" } +smallvec = { version = "1.0", features = ["union", "may_dangle"] } +rustc_session = { path = "../librustc_session" } +syntax = { path = "../libsyntax" } diff --git a/src/libsyntax/attr/builtin.rs b/src/librustc_attr/builtin.rs similarity index 99% rename from src/libsyntax/attr/builtin.rs rename to src/librustc_attr/builtin.rs index 1da005d70d4..f13f19073ea 100644 --- a/src/libsyntax/attr/builtin.rs +++ b/src/librustc_attr/builtin.rs @@ -1,16 +1,16 @@ //! Parsing and validation of builtin attributes -use super::{mark_used, MetaItemKind}; -use crate::ast::{self, Attribute, MetaItem, NestedMetaItem}; -use crate::print::pprust; -use crate::sess::{feature_err, ParseSess}; +use super::mark_used; use rustc_errors::{struct_span_err, Applicability, Handler}; use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg}; use rustc_macros::HashStable_Generic; +use rustc_session::parse::{feature_err, ParseSess}; use rustc_span::hygiene::Transparency; use rustc_span::{symbol::sym, symbol::Symbol, Span}; use std::num::NonZeroU32; +use syntax::ast::{self, Attribute, MetaItem, MetaItemKind, NestedMetaItem}; +use syntax::print::pprust; pub fn is_builtin_attr(attr: &Attribute) -> bool { attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some() diff --git a/src/librustc_attr/lib.rs b/src/librustc_attr/lib.rs new file mode 100644 index 00000000000..d2ff167db88 --- /dev/null +++ b/src/librustc_attr/lib.rs @@ -0,0 +1,16 @@ +//! Functions and types dealing with attributes and meta items. +//! +//! FIXME(Centril): For now being, much of the logic is still in `syntax::attr`. +//! The goal is to move the definition of `MetaItem` and things that don't need to be in `syntax` +//! to this crate. + +mod builtin; + +pub use builtin::*; +pub use IntType::*; +pub use ReprAttr::*; +pub use StabilityLevel::*; + +pub use syntax::attr::*; + +pub(crate) use syntax::HashStableContext; diff --git a/src/librustc_builtin_macros/Cargo.toml b/src/librustc_builtin_macros/Cargo.toml index 3ce7f5d770e..d0558a50acf 100644 --- a/src/librustc_builtin_macros/Cargo.toml +++ b/src/librustc_builtin_macros/Cargo.toml @@ -12,6 +12,7 @@ doctest = false [dependencies] fmt_macros = { path = "../libfmt_macros" } log = "0.4" +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_feature = { path = "../librustc_feature" } diff --git a/src/librustc_builtin_macros/cfg.rs b/src/librustc_builtin_macros/cfg.rs index cee62a54f00..c9a77ee0acd 100644 --- a/src/librustc_builtin_macros/cfg.rs +++ b/src/librustc_builtin_macros/cfg.rs @@ -2,11 +2,11 @@ //! a literal `true` or `false` based on whether the given cfg matches the //! current compilation environment. +use rustc_attr as attr; use rustc_errors::DiagnosticBuilder; use rustc_expand::base::{self, *}; use rustc_span::Span; use syntax::ast; -use syntax::attr; use syntax::token; use syntax::tokenstream::TokenStream; diff --git a/src/librustc_builtin_macros/deriving/generic/mod.rs b/src/librustc_builtin_macros/deriving/generic/mod.rs index 9377f194dcd..d0208cb33a7 100644 --- a/src/librustc_builtin_macros/deriving/generic/mod.rs +++ b/src/librustc_builtin_macros/deriving/generic/mod.rs @@ -181,13 +181,13 @@ use std::cell::RefCell; use std::iter; use std::vec; +use rustc_attr as attr; use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_span::source_map::respan; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind}; use syntax::ast::{GenericArg, GenericParamKind, VariantData}; -use syntax::attr; use syntax::ptr::P; use syntax::sess::ParseSess; use syntax::util::map_in_place::MapInPlace; diff --git a/src/librustc_codegen_llvm/Cargo.toml b/src/librustc_codegen_llvm/Cargo.toml index dd9eadde098..e7c0ee5ea76 100644 --- a/src/librustc_codegen_llvm/Cargo.toml +++ b/src/librustc_codegen_llvm/Cargo.toml @@ -17,6 +17,7 @@ libc = "0.2" log = "0.4" rustc = { path = "../librustc" } rustc-demangle = "0.1" +rustc_attr = { path = "../librustc_attr" } rustc_codegen_ssa = { path = "../librustc_codegen_ssa" } rustc_codegen_utils = { path = "../librustc_codegen_utils" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index fc1b365cf90..e3920d99c90 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -21,7 +21,7 @@ use crate::attributes; use crate::llvm::AttributePlace::Function; use crate::llvm::{self, Attribute}; use crate::llvm_util; -pub use syntax::attr::{self, InlineAttr, OptimizeAttr}; +pub use rustc_attr::{self as attr, InlineAttr, OptimizeAttr}; use crate::context::CodegenCx; use crate::value::Value; diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml index 9f8b4e72a9c..8d767e5c2a0 100644 --- a/src/librustc_codegen_ssa/Cargo.toml +++ b/src/librustc_codegen_ssa/Cargo.toml @@ -24,6 +24,7 @@ syntax = { path = "../libsyntax" } rustc_span = { path = "../librustc_span" } rustc = { path = "../librustc" } rustc_apfloat = { path = "../librustc_apfloat" } +rustc_attr = { path = "../librustc_attr" } rustc_codegen_utils = { path = "../librustc_codegen_utils" } rustc_data_structures = { path = "../librustc_data_structures"} rustc_errors = { path = "../librustc_errors" } diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index f56a4170c0a..71920020091 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -1719,7 +1719,7 @@ pub fn add_upstream_native_libraries( pub fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { match lib.cfg { - Some(ref cfg) => syntax::attr::cfg_matches(cfg, &sess.parse_sess, None), + Some(ref cfg) => rustc_attr::cfg_matches(cfg, &sess.parse_sess, None), None => true, } } diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index efd56007120..1f43a4027c5 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -37,6 +37,7 @@ use rustc::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyLayout, VariantIdx}; use rustc::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA}; use rustc::ty::query::Providers; use rustc::ty::{self, Instance, Ty, TyCtxt}; +use rustc_attr as attr; use rustc_codegen_utils::{check_for_rustc_errors_attr, symbol_names_test}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::profiling::print_time_passes_entry; @@ -46,7 +47,6 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_index::vec::Idx; use rustc_session::cgu_reuse_tracker::CguReuse; use rustc_span::Span; -use syntax::attr; use std::cmp; use std::ops::{Deref, DerefMut}; diff --git a/src/librustc_expand/Cargo.toml b/src/librustc_expand/Cargo.toml index d04dd079be7..1310e7fbd09 100644 --- a/src/librustc_expand/Cargo.toml +++ b/src/librustc_expand/Cargo.toml @@ -15,6 +15,7 @@ rustc_serialize = { path = "../libserialize", package = "serialize" } log = "0.4" rustc_span = { path = "../librustc_span" } rustc_ast_passes = { path = "../librustc_ast_passes" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_feature = { path = "../librustc_feature" } diff --git a/src/librustc_expand/base.rs b/src/librustc_expand/base.rs index af02070828a..52e5798ec19 100644 --- a/src/librustc_expand/base.rs +++ b/src/librustc_expand/base.rs @@ -1,5 +1,6 @@ use crate::expand::{self, AstFragment, Invocation}; +use rustc_attr::{self as attr, Deprecation, HasAttrs, Stability}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::{self, Lrc}; use rustc_errors::{DiagnosticBuilder, DiagnosticId}; @@ -11,7 +12,6 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{FileName, MultiSpan, Span, DUMMY_SP}; use smallvec::{smallvec, SmallVec}; use syntax::ast::{self, Attribute, Name, NodeId, PatKind}; -use syntax::attr::{self, Deprecation, HasAttrs, Stability}; use syntax::mut_visit::{self, MutVisitor}; use syntax::ptr::P; use syntax::sess::ParseSess; diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs index 910a0e52e53..35b6b96d49b 100644 --- a/src/librustc_expand/expand.rs +++ b/src/librustc_expand/expand.rs @@ -5,6 +5,7 @@ use crate::mbe::macro_rules::annotate_err_with_kind; use crate::placeholders::{placeholder, PlaceholderExpander}; use crate::proc_macro::collect_derives; +use rustc_attr::{self as attr, is_builtin_attr, HasAttrs}; use rustc_data_structures::sync::Lrc; use rustc_errors::{Applicability, FatalError, PResult}; use rustc_feature::Features; @@ -17,7 +18,6 @@ use rustc_span::symbol::{sym, Symbol}; use rustc_span::{FileName, Span, DUMMY_SP}; use syntax::ast::{self, AttrItem, Block, Ident, LitKind, NodeId, PatKind, Path}; use syntax::ast::{ItemKind, MacArgs, MacStmtStyle, StmtKind}; -use syntax::attr::{self, is_builtin_attr, HasAttrs}; use syntax::mut_visit::*; use syntax::print::pprust; use syntax::ptr::P; diff --git a/src/librustc_expand/mbe/macro_rules.rs b/src/librustc_expand/mbe/macro_rules.rs index d72317af9eb..3dbe8e7983c 100644 --- a/src/librustc_expand/mbe/macro_rules.rs +++ b/src/librustc_expand/mbe/macro_rules.rs @@ -8,6 +8,7 @@ use crate::mbe::macro_parser::{Error, Failure, Success}; use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedParseResult}; use crate::mbe::transcribe::transcribe; +use rustc_attr::{self as attr, TransparencyError}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; use rustc_errors::{Applicability, DiagnosticBuilder, FatalError}; @@ -19,7 +20,6 @@ use rustc_span::hygiene::Transparency; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; use syntax::ast; -use syntax::attr::{self, TransparencyError}; use syntax::print::pprust; use syntax::sess::ParseSess; use syntax::token::{self, NtTT, Token, TokenKind::*}; diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml index 1fe5248dbf4..de7a9f4f5af 100644 --- a/src/librustc_interface/Cargo.toml +++ b/src/librustc_interface/Cargo.toml @@ -14,6 +14,7 @@ log = "0.4" rayon = { version = "0.3.0", package = "rustc-rayon" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } syntax = { path = "../libsyntax" } +rustc_attr = { path = "../librustc_attr" } rustc_builtin_macros = { path = "../librustc_builtin_macros" } rustc_expand = { path = "../librustc_expand" } rustc_parse = { path = "../librustc_parse" } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 6bda85ded2b..56121fba2d5 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -32,7 +32,7 @@ use syntax::ast::{AttrVec, BlockCheckMode}; use syntax::mut_visit::{visit_clobber, MutVisitor, *}; use syntax::ptr::P; use syntax::util::lev_distance::find_best_match_for_name; -use syntax::{self, ast, attr}; +use syntax::{self, ast}; /// Adds `target_feature = "..."` cfgs for a variety of platform /// specific features (SSE, NEON etc.). @@ -547,7 +547,7 @@ pub fn build_output_filenames( .opts .crate_name .clone() - .or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string())) + .or_else(|| rustc_attr::find_crate_name(attrs).map(|n| n.to_string())) .unwrap_or_else(|| input.filestem().to_owned()); OutputFilenames::new( diff --git a/src/librustc_lint/Cargo.toml b/src/librustc_lint/Cargo.toml index 7e23e705779..d32622c09c6 100644 --- a/src/librustc_lint/Cargo.toml +++ b/src/librustc_lint/Cargo.toml @@ -12,6 +12,7 @@ path = "lib.rs" log = "0.4" unicode-security = "0.0.2" rustc = { path = "../librustc" } +rustc_attr = { path = "../librustc_attr" } rustc_errors = { path = "../librustc_errors" } rustc_hir = { path = "../librustc_hir" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index 394da4a5bb0..6fdbfea7f03 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -1,5 +1,6 @@ use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc::ty; +use rustc_attr as attr; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -9,7 +10,6 @@ use rustc_span::symbol::sym; use rustc_span::{symbol::Ident, BytePos, Span}; use rustc_target::spec::abi::Abi; use syntax::ast; -use syntax::attr; #[derive(PartialEq)] pub enum MethodLateContext { diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index d96ba59d9a3..6bc6f58f3e7 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -5,6 +5,7 @@ use rustc::mir::interpret::{sign_extend, truncate}; use rustc::ty::layout::{self, IntegerExt, LayoutOf, SizeSkeleton, VariantIdx}; use rustc::ty::subst::SubstsRef; use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; +use rustc_attr as attr; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir as hir; @@ -15,7 +16,7 @@ use rustc_span::source_map; use rustc_span::symbol::sym; use rustc_span::Span; use rustc_target::spec::abi::Abi; -use syntax::{ast, attr}; +use syntax::ast; use log::debug; use std::cmp; diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index 6da584733ae..a74f886043b 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -15,6 +15,7 @@ log = "0.4" memmap = "0.7" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc = { path = "../librustc" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_hir = { path = "../librustc_hir" } diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index bbf6973be51..2fa9cb099dd 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -2,6 +2,7 @@ use rustc::middle::cstore::{self, NativeLibrary}; use rustc::session::parse::feature_err; use rustc::session::Session; use rustc::ty::TyCtxt; +use rustc_attr as attr; use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; use rustc_hir as hir; @@ -9,7 +10,6 @@ use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_span::source_map::Span; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_target::spec::abi::Abi; -use syntax::attr; crate fn collect(tcx: TyCtxt<'_>) -> Vec { let mut collector = Collector { tcx, libs: Vec::new() }; diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index 6280121f655..58cf142ab3a 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -34,6 +34,7 @@ use std::u32; use log::debug; use proc_macro::bridge::client::ProcMacro; +use rustc_attr as attr; use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, ProcMacroDerive}; use rustc_serialize::{opaque, Decodable, Decoder, SpecializedDecoder}; @@ -41,7 +42,6 @@ use rustc_span::source_map::{self, respan, Spanned}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{self, hygiene::MacroKind, BytePos, Pos, Span, DUMMY_SP}; use syntax::ast::{self, Ident}; -use syntax::attr; pub use cstore_impl::{provide, provide_extern}; diff --git a/src/librustc_metadata/rmeta/mod.rs b/src/librustc_metadata/rmeta/mod.rs index 426ea62b8cd..77ec3eb4555 100644 --- a/src/librustc_metadata/rmeta/mod.rs +++ b/src/librustc_metadata/rmeta/mod.rs @@ -10,6 +10,7 @@ use rustc::mir; use rustc::session::config::SymbolManglingVersion; use rustc::session::CrateDisambiguator; use rustc::ty::{self, ReprOptions, Ty}; +use rustc_attr as attr; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::MetadataRef; use rustc_hir as hir; @@ -21,7 +22,7 @@ use rustc_span::edition::Edition; use rustc_span::symbol::Symbol; use rustc_span::{self, Span}; use rustc_target::spec::{PanicStrategy, TargetTriple}; -use syntax::{ast, attr}; +use syntax::ast; use std::marker::PhantomData; use std::num::NonZeroUsize; diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index 00881e3ea6f..eead88dcb0c 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -17,6 +17,7 @@ log = "0.4" log_settings = "0.1.1" polonius-engine = "0.11.0" rustc = { path = "../librustc" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_hir = { path = "../librustc_hir" } diff --git a/src/librustc_mir/const_eval/fn_queries.rs b/src/librustc_mir/const_eval/fn_queries.rs index 5eeb92f583b..4144bbc41d2 100644 --- a/src/librustc_mir/const_eval/fn_queries.rs +++ b/src/librustc_mir/const_eval/fn_queries.rs @@ -1,11 +1,11 @@ use rustc::hir::map::blocks::FnLikeNode; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; +use rustc_attr as attr; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_span::symbol::Symbol; use rustc_target::spec::abi::Abi; -use syntax::attr; /// Whether the `def_id` counts as const fn in your current crate, considering all active /// feature gates diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 56b6fa68e18..a3cafcb5763 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -16,8 +16,8 @@ use crate::transform::{MirPass, MirSource}; use std::collections::VecDeque; use std::iter; +use rustc_attr as attr; use rustc_target::spec::abi::Abi; -use syntax::attr; const DEFAULT_THRESHOLD: usize = 50; const HINT_THRESHOLD: usize = 100; diff --git a/src/librustc_mir_build/Cargo.toml b/src/librustc_mir_build/Cargo.toml index a22c4d18d51..9ff3ed1a935 100644 --- a/src/librustc_mir_build/Cargo.toml +++ b/src/librustc_mir_build/Cargo.toml @@ -15,6 +15,7 @@ itertools = "0.8" log = "0.4" rustc = { path = "../librustc" } rustc_apfloat = { path = "../librustc_apfloat" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_index = { path = "../librustc_index" } rustc_errors = { path = "../librustc_errors" } diff --git a/src/librustc_mir_build/build/matches/simplify.rs b/src/librustc_mir_build/build/matches/simplify.rs index fb3babca32b..77bbce2d37a 100644 --- a/src/librustc_mir_build/build/matches/simplify.rs +++ b/src/librustc_mir_build/build/matches/simplify.rs @@ -18,8 +18,8 @@ use crate::hair::{self, *}; use rustc::mir::interpret::truncate; use rustc::ty; use rustc::ty::layout::{Integer, IntegerExt, Size}; +use rustc_attr::{SignedInt, UnsignedInt}; use rustc_hir::RangeEnd; -use syntax::attr::{SignedInt, UnsignedInt}; use std::mem; diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index fa5f266c76b..1f536b63a39 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -7,6 +7,7 @@ use rustc::middle::region; use rustc::mir::*; use rustc::ty::subst::Subst; use rustc::ty::{self, Ty, TyCtxt}; +use rustc_attr::{self as attr, UnwindAttr}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::{GeneratorKind, HirIdMap, Node}; @@ -16,7 +17,6 @@ use rustc_span::Span; use rustc_target::spec::abi::Abi; use rustc_target::spec::PanicStrategy; use std::u32; -use syntax::attr::{self, UnwindAttr}; use super::lints; diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs index 08ed6b521b5..4f0e5bb4582 100644 --- a/src/librustc_mir_build/hair/pattern/_match.rs +++ b/src/librustc_mir_build/hair/pattern/_match.rs @@ -245,8 +245,8 @@ use rustc::mir::interpret::{truncate, AllocId, ConstValue, Pointer, Scalar}; use rustc::mir::Field; use rustc::util::common::ErrorReported; +use rustc_attr::{SignedInt, UnsignedInt}; use rustc_span::{Span, DUMMY_SP}; -use syntax::attr::{SignedInt, UnsignedInt}; use arena::TypedArena; diff --git a/src/librustc_mir_build/hair/pattern/mod.rs b/src/librustc_mir_build/hair/pattern/mod.rs index 26570505830..bd8a9877719 100644 --- a/src/librustc_mir_build/hair/pattern/mod.rs +++ b/src/librustc_mir_build/hair/pattern/mod.rs @@ -1036,7 +1036,7 @@ crate fn compare_const_vals<'tcx>( } ty::Int(ity) => { use rustc::ty::layout::{Integer, IntegerExt}; - use syntax::attr::SignedInt; + use rustc_attr::SignedInt; let size = Integer::from_attr(&tcx, SignedInt(ity)).size(); let a = sign_extend(a, size); let b = sign_extend(b, size); diff --git a/src/librustc_parse/Cargo.toml b/src/librustc_parse/Cargo.toml index 8071bc6312b..6b0b6db8ed4 100644 --- a/src/librustc_parse/Cargo.toml +++ b/src/librustc_parse/Cargo.toml @@ -12,6 +12,7 @@ doctest = false [dependencies] bitflags = "1.0" log = "0.4" +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_feature = { path = "../librustc_feature" } rustc_lexer = { path = "../librustc_lexer" } diff --git a/src/librustc_parse/config.rs b/src/librustc_parse/config.rs index da158e17f25..d97fe621174 100644 --- a/src/librustc_parse/config.rs +++ b/src/librustc_parse/config.rs @@ -9,6 +9,7 @@ //! [#64197]: https://github.com/rust-lang/rust/issues/64197 use crate::{parse_in, validate_attr}; +use rustc_attr as attr; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{error_code, struct_span_err, Applicability, Handler}; use rustc_feature::{Feature, Features, State as FeatureState}; @@ -19,7 +20,6 @@ use rustc_span::edition::{Edition, ALL_EDITIONS}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{Span, DUMMY_SP}; use syntax::ast::{self, AttrItem, Attribute, MetaItem}; -use syntax::attr; use syntax::attr::HasAttrs; use syntax::mut_visit::*; use syntax::ptr::P; diff --git a/src/librustc_passes/Cargo.toml b/src/librustc_passes/Cargo.toml index 338808f6d4a..981ef7f8796 100644 --- a/src/librustc_passes/Cargo.toml +++ b/src/librustc_passes/Cargo.toml @@ -11,6 +11,7 @@ path = "lib.rs" [dependencies] log = "0.4" rustc = { path = "../librustc" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_feature = { path = "../librustc_feature" } diff --git a/src/librustc_passes/stability.rs b/src/librustc_passes/stability.rs index db8109c2859..4009cc6d725 100644 --- a/src/librustc_passes/stability.rs +++ b/src/librustc_passes/stability.rs @@ -10,6 +10,7 @@ use rustc::session::Session; use rustc::traits::misc::can_type_implement_copy; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; +use rustc_attr::{self as attr, Stability}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::struct_span_err; use rustc_hir as hir; @@ -20,7 +21,6 @@ use rustc_hir::{Generics, HirId, Item, StructField, Variant}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use syntax::ast::Attribute; -use syntax::attr::{self, Stability}; use std::cmp::Ordering; use std::mem::replace; diff --git a/src/librustc_privacy/Cargo.toml b/src/librustc_privacy/Cargo.toml index 4f341b54515..2f7aaf9e5cf 100644 --- a/src/librustc_privacy/Cargo.toml +++ b/src/librustc_privacy/Cargo.toml @@ -10,6 +10,7 @@ path = "lib.rs" [dependencies] rustc = { path = "../librustc" } +rustc_attr = { path = "../librustc_attr" } rustc_errors = { path = "../librustc_errors" } rustc_hir = { path = "../librustc_hir" } rustc_typeck = { path = "../librustc_typeck" } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 60bf271d2d2..74bb72d6fad 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -11,6 +11,7 @@ use rustc::ty::fold::TypeVisitor; use rustc::ty::query::Providers; use rustc::ty::subst::InternalSubsts; use rustc::ty::{self, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeFoldable}; +use rustc_attr as attr; use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; use rustc_hir as hir; @@ -22,7 +23,6 @@ use rustc_span::hygiene::Transparency; use rustc_span::symbol::{kw, sym}; use rustc_span::Span; use syntax::ast::Ident; -use syntax::attr; use std::marker::PhantomData; use std::{cmp, fmt, mem}; diff --git a/src/librustc_resolve/Cargo.toml b/src/librustc_resolve/Cargo.toml index c4cc6b09c73..74f0d247492 100644 --- a/src/librustc_resolve/Cargo.toml +++ b/src/librustc_resolve/Cargo.toml @@ -17,6 +17,7 @@ syntax = { path = "../libsyntax" } arena = { path = "../libarena" } rustc = { path = "../librustc" } rustc_ast_lowering = { path = "../librustc_ast_lowering" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_expand = { path = "../librustc_expand" } diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 7ff076268ab..c77b588d7fb 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -20,6 +20,7 @@ use rustc::bug; use rustc::hir::exports::Export; use rustc::middle::cstore::CrateStore; use rustc::ty; +use rustc_attr as attr; use rustc_data_structures::sync::Lrc; use rustc_errors::{struct_span_err, Applicability}; use rustc_expand::base::SyntaxExtension; @@ -34,7 +35,6 @@ use rustc_span::{Span, DUMMY_SP}; use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId}; use syntax::ast::{AssocItem, AssocItemKind, MetaItemKind, StmtKind}; use syntax::ast::{Ident, Name}; -use syntax::attr; use syntax::token::{self, Token}; use syntax::visit::{self, Visitor}; diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 85b5d8ef1cb..966638db493 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -10,6 +10,7 @@ use rustc::middle::stability; use rustc::session::parse::feature_err; use rustc::session::Session; use rustc::{lint, span_bug, ty}; +use rustc_attr::{self as attr, StabilityLevel}; use rustc_data_structures::fx::FxHashSet; use rustc_expand::base::SyntaxExtension; use rustc_expand::base::{self, Indeterminate, InvocationRes}; @@ -23,7 +24,6 @@ use rustc_span::hygiene::{self, ExpnData, ExpnId, ExpnKind}; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::{Span, DUMMY_SP}; use syntax::ast::{self, Ident, NodeId}; -use syntax::attr::{self, StabilityLevel}; use syntax::print::pprust; use rustc_data_structures::sync::Lrc; diff --git a/src/librustc_typeck/Cargo.toml b/src/librustc_typeck/Cargo.toml index 4b27d86dd02..748bfcc7946 100644 --- a/src/librustc_typeck/Cargo.toml +++ b/src/librustc_typeck/Cargo.toml @@ -14,6 +14,7 @@ doctest = false arena = { path = "../libarena" } log = "0.4" rustc = { path = "../librustc" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_hir = { path = "../librustc_hir" } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4d1f92d19ce..0a917a1853e 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -115,6 +115,7 @@ use rustc::ty::{ self, AdtKind, CanonicalUserType, Const, GenericParamDefKind, RegionKind, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, UserType, WithConstness, }; +use rustc_attr as attr; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticId}; @@ -131,7 +132,6 @@ use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::{self, BytePos, MultiSpan, Span}; use rustc_target::spec::abi::Abi; use syntax::ast; -use syntax::attr; use syntax::util::parser::ExprPrecedence; use std::cell::{Cell, Ref, RefCell, RefMut}; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 843872d0ff9..4d812d2621c 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -33,6 +33,7 @@ use rustc::ty::util::Discr; use rustc::ty::util::IntTypeExt; use rustc::ty::{self, AdtKind, Const, DefIdTree, ToPolyTraitRef, Ty, TyCtxt, WithConstness}; use rustc::ty::{ReprOptions, ToPredicate}; +use rustc_attr::{list_contains_name, mark_used, InlineAttr, OptimizeAttr}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{struct_span_err, Applicability, StashKey}; @@ -46,7 +47,6 @@ use rustc_span::{Span, DUMMY_SP}; use rustc_target::spec::abi; use syntax::ast; use syntax::ast::{Ident, MetaItemKind}; -use syntax::attr::{list_contains_name, mark_used, InlineAttr, OptimizeAttr}; struct OnlySelfBounds(bool); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 281306cc0c5..2a35ab812a5 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -16,6 +16,7 @@ use rustc::middle::stability; use rustc::ty::fold::TypeFolder; use rustc::ty::subst::InternalSubsts; use rustc::ty::{self, AdtKind, Lift, Ty, TyCtxt}; +use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; @@ -27,7 +28,6 @@ use rustc_span::symbol::{kw, sym}; use rustc_span::{self, Pos}; use rustc_typeck::hir_ty_to_ty; use syntax::ast::{self, Ident}; -use syntax::attr; use std::collections::hash_map::Entry; use std::default::Default; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 1c0e0b3bf41..a8baa89c6f1 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -15,13 +15,13 @@ use rustc_lint; use rustc_resolve as resolve; use rustc_session::lint; +use rustc_attr as attr; use rustc_errors::emitter::{Emitter, EmitterWriter}; use rustc_errors::json::JsonEmitter; use rustc_span::source_map; use rustc_span::symbol::sym; use rustc_span::DUMMY_SP; use syntax::ast::CRATE_NODE_ID; -use syntax::attr; use rustc_data_structures::sync::{self, Lrc}; use std::cell::RefCell; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 403c8d0160d..27a6a52c026 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -21,6 +21,7 @@ extern crate env_logger; extern crate getopts; extern crate rustc; +extern crate rustc_attr; extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_errors; diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index a78fbe276fa..e4d4017a345 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -1,12 +1,5 @@ //! Functions dealing with attributes and meta items. -mod builtin; - -pub use builtin::*; -pub use IntType::*; -pub use ReprAttr::*; -pub use StabilityLevel::*; - use crate::ast; use crate::ast::{AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute}; use crate::ast::{Expr, GenericParam, Item, Lit, LitKind, Local, Stmt, StmtKind};