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.
This commit is contained in:
Mazdak Farrokhzad 2020-01-11 13:15:20 +01:00
parent 9be73dc63a
commit 93a8283614
63 changed files with 133 additions and 53 deletions

View File

@ -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",

View File

@ -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" }

View File

@ -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]

View File

@ -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 {

View File

@ -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;

View File

@ -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)]

View File

@ -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);

View File

@ -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<Interned<'tcx, T>, ()>;

View File

@ -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;

View File

@ -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::*;

View File

@ -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;

View File

@ -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;

View File

@ -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> {

View File

@ -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" }

View File

@ -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() {

View File

@ -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" }

View File

@ -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()

16
src/librustc_attr/lib.rs Normal file
View File

@ -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;

View File

@ -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" }

View File

@ -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;

View File

@ -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;

View File

@ -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" }

View File

@ -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;

View File

@ -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" }

View File

@ -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,
}
}

View File

@ -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};

View File

@ -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" }

View File

@ -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;

View File

@ -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;

View File

@ -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::*};

View File

@ -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" }

View File

@ -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(

View File

@ -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" }

View File

@ -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 {

View File

@ -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;

View File

@ -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" }

View File

@ -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<NativeLibrary> {
let mut collector = Collector { tcx, libs: Vec::new() };

View File

@ -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};

View File

@ -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;

View File

@ -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" }

View File

@ -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

View File

@ -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;

View File

@ -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" }

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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" }

View File

@ -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;

View File

@ -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" }

View File

@ -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;

View File

@ -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" }

View File

@ -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};

View File

@ -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" }

View File

@ -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};

View File

@ -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;

View File

@ -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" }

View File

@ -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};

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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};