Auto merge of #68133 - Centril:slimmer-syntax, r=petrochenkov

Slimmer syntax

High-level summary of changes:

- The `syntax::node_count` pass is moved into `rustc_ast_passes`. This works towards improving #65031 by making compiling `syntax` go faster.

- The `syntax::{GLOBALS, with_globals, ..}` business is consolidated into `syntax::attr` for cleaner code and future possible improvements.

- The pretty printer loses its dependency on `ParseSess`, opting to use `SourceMap` & friends directly instead.

- Some drive by cleanup of `syntax::attr::HasAttr` happens.

- Builtin attribute logic (`syntax::attr::builtin`) + `syntax::attr::allow_internal_unstable` is moved into a new `rustc_attr` crate. More logic from `syntax::attr` should be moved into that crate over time. This also means that `syntax` loses all mentions of `ParseSess`, which enables the next point.

- The pretty printer `syntax::print` is moved into a new crate `rustc_ast_pretty`.

- `rustc_session::node_id` is moved back as `syntax::node_id`. As a result, `syntax` gets to drop dependencies on `rustc_session` (and implicitly `rustc_target`), `rustc_error_codes`, and `rustc_errors`. Moreover `rustc_hir` gets to drop its dependency on `rustc_session` as well. At this point, these crates are mostly "pure data crates", which is approaching a desirable end state.

  - We should consider renaming `syntax` to `rustc_ast` now.
This commit is contained in:
bors 2020-02-01 18:29:09 +00:00
commit 13db6501c7
139 changed files with 451 additions and 358 deletions

View file

@ -3093,6 +3093,7 @@ dependencies = [
"rustc-rayon",
"rustc-rayon-core",
"rustc_apfloat",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
@ -3358,6 +3359,7 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
@ -3374,6 +3376,8 @@ name = "rustc_ast_passes"
version = "0.0.0"
dependencies = [
"log",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
@ -3383,12 +3387,40 @@ dependencies = [
"syntax",
]
[[package]]
name = "rustc_ast_pretty"
version = "0.0.0"
dependencies = [
"log",
"rustc_data_structures",
"rustc_span",
"syntax",
]
[[package]]
name = "rustc_attr"
version = "0.0.0"
dependencies = [
"rustc_ast_pretty",
"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_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_expand",
@ -3411,6 +3443,7 @@ dependencies = [
"log",
"rustc",
"rustc-demangle",
"rustc_attr",
"rustc_codegen_ssa",
"rustc_codegen_utils",
"rustc_data_structures",
@ -3442,6 +3475,7 @@ dependencies = [
"num_cpus",
"rustc",
"rustc_apfloat",
"rustc_attr",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_errors",
@ -3506,6 +3540,7 @@ dependencies = [
"lazy_static 1.4.0",
"log",
"rustc",
"rustc_ast_pretty",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_error_codes",
@ -3552,6 +3587,8 @@ version = "0.0.0"
dependencies = [
"log",
"rustc_ast_passes",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
@ -3581,11 +3618,11 @@ version = "0.0.0"
name = "rustc_hir"
version = "0.0.0"
dependencies = [
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_macros",
"rustc_session",
"rustc_span",
"rustc_target",
"serialize",
@ -3628,6 +3665,7 @@ dependencies = [
"rustc-rayon",
"rustc_ast_lowering",
"rustc_ast_passes",
"rustc_attr",
"rustc_builtin_macros",
"rustc_codegen_llvm",
"rustc_codegen_ssa",
@ -3672,6 +3710,8 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
@ -3712,6 +3752,8 @@ dependencies = [
"log",
"memmap",
"rustc",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_expand",
@ -3739,6 +3781,8 @@ dependencies = [
"polonius-engine",
"rustc",
"rustc_apfloat",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
@ -3761,6 +3805,7 @@ dependencies = [
"log",
"rustc",
"rustc_apfloat",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
@ -3780,6 +3825,8 @@ version = "0.0.0"
dependencies = [
"bitflags",
"log",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
@ -3797,6 +3844,7 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
@ -3827,6 +3875,7 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
@ -3844,6 +3893,8 @@ dependencies = [
"log",
"rustc",
"rustc_ast_lowering",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_expand",
@ -3864,6 +3915,7 @@ dependencies = [
"rls-data",
"rls-span",
"rustc",
"rustc_ast_pretty",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_hir",
@ -3887,6 +3939,7 @@ dependencies = [
"rustc_span",
"rustc_target",
"serialize",
"syntax",
]
[[package]]
@ -3961,6 +4014,7 @@ dependencies = [
"arena",
"log",
"rustc",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
@ -4481,12 +4535,9 @@ version = "0.0.0"
dependencies = [
"log",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
"rustc_index",
"rustc_lexer",
"rustc_macros",
"rustc_session",
"rustc_span",
"scoped-tls",
"serialize",

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

@ -10,12 +10,12 @@ use rustc_data_structures::stable_hasher::StableHasher;
use rustc_hir as hir;
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_index::vec::IndexVec;
use rustc_session::node_id::NodeMap;
use rustc_session::CrateDisambiguator;
use rustc_span::hygiene::ExpnId;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
use syntax::ast;
use syntax::node_id::NodeMap;
use std::borrow::Borrow;
use std::fmt::Write;

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;
@ -12,12 +13,12 @@ use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX};
use rustc_hir::{self, HirId};
use rustc_session::lint::{self, BuiltinLintDiagnostics, Lint, LintBuffer};
use rustc_session::lint::builtin::{DEPRECATED, DEPRECATED_IN_FUTURE, SOFT_UNSTABLE};
use rustc_session::lint::{BuiltinLintDiagnostics, Lint, LintBuffer};
use rustc_session::parse::feature_err_issue;
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;
@ -97,7 +98,7 @@ pub fn report_unstable(
issue: Option<NonZeroU32>,
is_soft: bool,
span: Span,
soft_handler: impl FnOnce(&'static lint::Lint, Span, &str),
soft_handler: impl FnOnce(&'static Lint, Span, &str),
) {
let msg = match reason {
Some(r) => format!("use of unstable library feature '{}': {}", feature, r),
@ -119,7 +120,7 @@ pub fn report_unstable(
let fresh = sess.one_time_diagnostics.borrow_mut().insert(error_id);
if fresh {
if is_soft {
soft_handler(lint::builtin::SOFT_UNSTABLE, span, &msg)
soft_handler(SOFT_UNSTABLE, span, &msg)
} else {
feature_err_issue(&sess.parse_sess, feature, span, GateIssue::Library(issue), &msg)
.emit();
@ -175,19 +176,19 @@ fn deprecation_message_common(message: String, reason: Option<Symbol>) -> String
pub fn deprecation_message(depr: &Deprecation, path: &str) -> (String, &'static Lint) {
let message = format!("use of deprecated item '{}'", path);
(deprecation_message_common(message, depr.note), lint::builtin::DEPRECATED)
(deprecation_message_common(message, depr.note), DEPRECATED)
}
pub fn rustc_deprecation_message(depr: &RustcDeprecation, path: &str) -> (String, &'static Lint) {
let (message, lint) = if deprecation_in_effect(&depr.since.as_str()) {
(format!("use of deprecated item '{}'", path), lint::builtin::DEPRECATED)
(format!("use of deprecated item '{}'", path), DEPRECATED)
} else {
(
format!(
"use of item '{}' that will be deprecated in future version {}",
path, depr.since
),
lint::builtin::DEPRECATED_IN_FUTURE,
DEPRECATED_IN_FUTURE,
)
};
(deprecation_message_common(message, Some(depr.reason)), lint)

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

@ -41,32 +41,34 @@ use crate::ty::{ExistentialPredicate, InferTy, ParamTy, PolyFnSig, Predicate, Pr
use crate::ty::{InferConst, ParamConst};
use crate::ty::{List, TyKind, TyS};
use crate::util::common::ErrorReported;
use rustc_data_structures::sync;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, DefIndex, LOCAL_CRATE};
use rustc_hir::{HirId, Node, TraitCandidate};
use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet};
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};
use rustc_data_structures::stable_hasher::{
hash_stable_hashmap, HashStable, StableHasher, StableVec,
};
use rustc_data_structures::sync::{Lock, Lrc, WorkerLocal};
use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
use rustc_errors::DiagnosticBuilder;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, DefIndex, LOCAL_CRATE};
use rustc_hir::{HirId, Node, TraitCandidate};
use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet};
use rustc_index::vec::{Idx, IndexVec};
use rustc_macros::HashStable;
use rustc_session::config::CrateType;
use rustc_session::config::{BorrowckMode, OutputFilenames};
use rustc_session::lint::{Level, Lint};
use rustc_session::node_id::NodeMap;
use rustc_session::Session;
use rustc_span::source_map::MultiSpan;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;
use rustc_target::spec::abi;
use syntax::ast;
use syntax::expand::allocator::AllocatorKind;
use syntax::node_id::NodeMap;
use smallvec::SmallVec;
use std::any::Any;
use std::borrow::Borrow;
@ -78,9 +80,6 @@ use std::iter;
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;
@ -38,11 +39,13 @@ use rustc_hir::{GlobMap, Node, TraitMap};
use rustc_index::vec::{Idx, IndexVec};
use rustc_macros::HashStable;
use rustc_serialize::{self, Encodable, Encoder};
use rustc_session::node_id::{NodeMap, NodeSet};
use rustc_span::hygiene::ExpnId;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;
use rustc_target::abi::Align;
use syntax::ast::{self, Constness, Ident, Name};
use syntax::node_id::{NodeId, NodeMap, NodeSet};
use smallvec;
use std::cell::RefCell;
use std::cmp::{self, Ordering};
@ -52,8 +55,6 @@ use std::ops::Deref;
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

@ -435,11 +435,11 @@ pub unsafe fn handle_deadlock() {
let rustc_span_globals =
rustc_span::GLOBALS.with(|rustc_span_globals| rustc_span_globals as *const _);
let rustc_span_globals = &*rustc_span_globals;
let syntax_globals = syntax::GLOBALS.with(|syntax_globals| syntax_globals as *const _);
let syntax_globals = syntax::attr::GLOBALS.with(|syntax_globals| syntax_globals as *const _);
let syntax_globals = &*syntax_globals;
thread::spawn(move || {
tls::GCX_PTR.set(gcx_ptr, || {
syntax::GLOBALS.set(syntax_globals, || {
syntax::attr::GLOBALS.set(syntax_globals, || {
rustc_span::GLOBALS
.set(rustc_span_globals, || tls::with_global(|tcx| deadlock(tcx, &registry)))
});

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

@ -12,6 +12,7 @@ doctest = false
[dependencies]
log = { version = "0.4", features = ["release_max_level_info", "std"] }
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_hir = { path = "../librustc_hir" }
rustc_target = { path = "../librustc_target" }
rustc_data_structures = { path = "../librustc_data_structures" }

View file

@ -7,13 +7,13 @@ use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_session::node_id::NodeMap;
use rustc_span::source_map::{respan, DesugaringKind};
use rustc_span::symbol::{kw, sym};
use rustc_span::Span;
use rustc_target::spec::abi;
use syntax::ast::*;
use syntax::attr;
use syntax::node_id::NodeMap;
use syntax::visit::{self, Visitor};
use log::debug;

View file

@ -38,6 +38,7 @@ use rustc::dep_graph::DepGraph;
use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions};
use rustc::hir::map::Map;
use rustc::{bug, span_bug};
use rustc_ast_pretty::pprust;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
@ -49,8 +50,8 @@ use rustc_hir::intravisit;
use rustc_hir::{ConstArg, GenericArg, ParamName};
use rustc_index::vec::IndexVec;
use rustc_session::config::nightly_options;
use rustc_session::lint::{builtin, BuiltinLintDiagnostics, LintBuffer};
use rustc_session::node_id::NodeMap;
use rustc_session::lint::{builtin::BARE_TRAIT_OBJECTS, BuiltinLintDiagnostics, LintBuffer};
use rustc_session::parse::ParseSess;
use rustc_session::Session;
use rustc_span::hygiene::ExpnId;
use rustc_span::source_map::{respan, DesugaringKind, ExpnData, ExpnKind};
@ -59,8 +60,7 @@ use rustc_span::Span;
use syntax::ast;
use syntax::ast::*;
use syntax::attr;
use syntax::print::pprust;
use syntax::sess::ParseSess;
use syntax::node_id::NodeMap;
use syntax::token::{self, Nonterminal, Token};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::visit::{self, Visitor};
@ -2621,7 +2621,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.unwrap_or(true);
if !is_macro_callsite {
self.resolver.lint_buffer().buffer_lint_with_diagnostic(
builtin::BARE_TRAIT_OBJECTS,
BARE_TRAIT_OBJECTS,
id,
span,
"trait objects without an explicit `dyn` are deprecated",

View file

@ -10,6 +10,8 @@ path = "lib.rs"
[dependencies]
log = "0.4"
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
rustc_feature = { path = "../librustc_feature" }

View file

@ -6,6 +6,7 @@
// This pass is supposed to perform only simple checks not requiring name resolution
// or type checking or some other kind of complex analysis.
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, Applicability, FatalError};
use rustc_parse::validate_attr;
@ -19,7 +20,6 @@ use std::mem;
use syntax::ast::*;
use syntax::attr;
use syntax::expand::is_proc_macro_attr;
use syntax::print::pprust;
use syntax::visit::{self, Visitor};
use syntax::walk_list;
@ -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

@ -1,13 +1,13 @@
use rustc_errors::{struct_span_err, Handler};
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP};
use rustc_feature::{Features, GateIssue, UnstableFeatures};
use rustc_session::parse::{feature_err, feature_err_issue, ParseSess};
use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym;
use rustc_span::Span;
use syntax::ast::{self, AssocTyConstraint, AssocTyConstraintKind, NodeId};
use syntax::ast::{GenericParam, GenericParamKind, PatKind, RangeEnd, VariantData};
use syntax::attr;
use syntax::sess::{feature_err, feature_err_issue, ParseSess};
use syntax::visit::{self, FnKind, Visitor};
use log::debug;

View file

@ -1,9 +1,12 @@
//! The `rustc_ast_passes` crate contains passes which validate the AST in `syntax`
//! parsed by `rustc_parse` and then lowered, after the passes in this crate,
//! by `rustc_ast_lowering`.
//!
//! The crate also contains other misc AST visitors, e.g. `node_count` and `show_span`.
#![cfg_attr(bootstrap, feature(slice_patterns))]
pub mod ast_validation;
pub mod feature_gate;
pub mod node_count;
pub mod show_span;

View file

@ -1,8 +1,8 @@
// Simply gives a rought count of the number of nodes in an AST.
use crate::ast::*;
use crate::visit::*;
use rustc_span::Span;
use syntax::ast::*;
use syntax::visit::*;
pub struct NodeCounter {
pub count: usize,

View file

@ -0,0 +1,16 @@
[package]
authors = ["The Rust Project Developers"]
name = "rustc_ast_pretty"
version = "0.0.0"
edition = "2018"
[lib]
name = "rustc_ast_pretty"
path = "lib.rs"
doctest = false
[dependencies]
log = "0.4"
rustc_span = { path = "../librustc_span" }
rustc_data_structures = { path = "../librustc_data_structures" }
syntax = { path = "../libsyntax" }

View file

@ -1,4 +1,4 @@
use crate::print::pp::Printer;
use crate::pp::Printer;
use std::borrow::Cow;
impl Printer {

View file

@ -0,0 +1,7 @@
#![feature(bool_to_option)]
#![feature(crate_visibility_modifier)]
#![recursion_limit = "256"]
mod helpers;
pub mod pp;
pub mod pprust;

View file

@ -1,20 +1,19 @@
use crate::ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax};
use crate::ast::{Attribute, GenericArg, MacArgs};
use crate::ast::{GenericBound, SelfKind, TraitBoundModifier};
use crate::attr;
use crate::print::pp::Breaks::{Consistent, Inconsistent};
use crate::print::pp::{self, Breaks};
use crate::ptr::P;
use crate::sess::ParseSess;
use crate::token::{self, BinOpToken, DelimToken, Nonterminal, Token, TokenKind};
use crate::tokenstream::{self, TokenStream, TokenTree};
use crate::util::classify;
use crate::util::comments;
use crate::util::parser::{self, AssocOp, Fixity};
use crate::pp::Breaks::{Consistent, Inconsistent};
use crate::pp::{self, Breaks};
use rustc_span::edition::Edition;
use rustc_span::source_map::{dummy_spanned, SourceMap, Spanned};
use rustc_span::symbol::{kw, sym};
use rustc_span::{BytePos, FileName, Span};
use syntax::ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax};
use syntax::ast::{Attribute, GenericArg, MacArgs};
use syntax::ast::{GenericBound, SelfKind, TraitBoundModifier};
use syntax::attr;
use syntax::ptr::P;
use syntax::token::{self, BinOpToken, DelimToken, Nonterminal, Token, TokenKind};
use syntax::tokenstream::{self, TokenStream, TokenTree};
use syntax::util::parser::{self, AssocOp, Fixity};
use syntax::util::{classify, comments};
use std::borrow::Cow;
@ -54,13 +53,8 @@ pub struct Comments<'a> {
}
impl<'a> Comments<'a> {
pub fn new(
cm: &'a SourceMap,
sess: &ParseSess,
filename: FileName,
input: String,
) -> Comments<'a> {
let comments = comments::gather_comments(sess, filename, input);
pub fn new(cm: &'a SourceMap, filename: FileName, input: String) -> Comments<'a> {
let comments = comments::gather_comments(cm, filename, input);
Comments { cm, comments, current: 0 }
}
@ -102,21 +96,22 @@ crate const INDENT_UNIT: usize = 4;
/// it can scan the input text for comments to copy forward.
pub fn print_crate<'a>(
cm: &'a SourceMap,
sess: &ParseSess,
krate: &ast::Crate,
filename: FileName,
input: String,
ann: &'a dyn PpAnn,
is_expanded: bool,
edition: Edition,
has_injected_crate: bool,
) -> String {
let mut s = State {
s: pp::mk_printer(),
comments: Some(Comments::new(cm, sess, filename, input)),
comments: Some(Comments::new(cm, filename, input)),
ann,
is_expanded,
};
if is_expanded && sess.injected_crate_name.try_get().is_some() {
if is_expanded && has_injected_crate {
// We need to print `#![no_std]` (and its feature gate) so that
// compiling pretty-printed source won't inject libstd again.
// However, we don't want these attributes in the AST because
@ -130,7 +125,7 @@ pub fn print_crate<'a>(
// Currently, in Rust 2018 we don't have `extern crate std;` at the crate
// root, so this is not needed, and actually breaks things.
if sess.edition == rustc_span::edition::Edition::Edition2015 {
if edition == Edition::Edition2015 {
// `#![no_std]`
let no_std_meta = attr::mk_word_item(ast::Ident::with_dummy_span(sym::no_std));
let fake_attr = attr::mk_attr_inner(no_std_meta);
@ -144,10 +139,7 @@ pub fn print_crate<'a>(
s.s.eof()
}
pub fn to_string<F>(f: F) -> String
where
F: FnOnce(&mut State<'_>),
{
pub fn to_string(f: impl FnOnce(&mut State<'_>)) -> String {
let mut printer =
State { s: pp::mk_printer(), comments: None, ann: &NoAnn, is_expanded: false };
f(&mut printer);

View file

@ -1,9 +1,9 @@
use super::*;
use crate::ast;
use crate::with_default_globals;
use rustc_span;
use rustc_span::source_map::{dummy_spanned, respan};
use syntax::ast;
use syntax::with_default_globals;
fn fun_to_string(
decl: &ast::FnDecl,

View file

@ -0,0 +1,22 @@
[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_ast_pretty = { path = "../librustc_ast_pretty" }
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::{find_by_name, mark_used};
use rustc_ast_pretty::pprust;
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};
pub fn is_builtin_attr(attr: &Attribute) -> bool {
attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some()
@ -1043,3 +1043,21 @@ pub fn find_transparency(
let fallback = if is_legacy { Transparency::SemiTransparent } else { Transparency::Opaque };
(transparency.map_or(fallback, |t| t.0), error)
}
pub fn allow_internal_unstable<'a>(
attrs: &[Attribute],
diag: &'a rustc_errors::Handler,
) -> Option<impl Iterator<Item = Symbol> + 'a> {
let attr = find_by_name(attrs, sym::allow_internal_unstable)?;
let list = attr.meta_item_list().or_else(|| {
diag.span_err(attr.span, "allow_internal_unstable expects list of feature names");
None
})?;
Some(list.into_iter().filter_map(move |it| {
let name = it.ident().map(|ident| ident.name);
if name.is_none() {
diag.span_err(it.span(), "`allow_internal_unstable` expects feature names");
}
name
}))
}

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,8 @@ doctest = false
[dependencies]
fmt_macros = { path = "../libfmt_macros" }
log = "0.4"
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
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,11 +1,11 @@
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_ast_pretty::pprust;
use rustc_expand::base::*;
use rustc_parse::parser::Parser;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{Span, DUMMY_SP};
use syntax::ast::{self, *};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, TokenKind};
use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree};

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

@ -1,10 +1,10 @@
//! Attributes injected into the crate root from command line using `-Z crate-attr`.
use rustc_expand::panictry;
use rustc_session::parse::ParseSess;
use rustc_span::FileName;
use syntax::ast::{self, AttrItem, AttrStyle};
use syntax::attr::mk_attr;
use syntax::sess::ParseSess;
use syntax::token;
pub fn inject(mut krate: ast::Crate, parse_sess: &ParseSess, attrs: &[String]) -> ast::Crate {

View file

@ -181,15 +181,15 @@ use std::cell::RefCell;
use std::iter;
use std::vec;
use rustc_attr as attr;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_session::parse::ParseSess;
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;
use ty::{LifetimeBounds, Path, Ptr, PtrTy, Self_, Ty};

View file

@ -1,6 +1,6 @@
use rustc_ast_pretty::pprust;
use rustc_expand::base;
use rustc_span;
use syntax::print;
use syntax::tokenstream::TokenStream;
pub fn expand_log_syntax<'cx>(
@ -8,7 +8,7 @@ pub fn expand_log_syntax<'cx>(
sp: rustc_span::Span,
tts: TokenStream,
) -> Box<dyn base::MacResult + 'cx> {
println!("{}", print::pprust::tts_to_string(tts));
println!("{}", pprust::tts_to_string(tts));
// any so that `log_syntax` can be invoked as an expression and item.
base::DummyResult::any_valid(sp)

View file

@ -1,7 +1,9 @@
use std::mem;
use rustc_ast_pretty::pprust;
use rustc_expand::base::{ExtCtxt, Resolver};
use rustc_expand::expand::{AstFragment, ExpansionConfig};
use rustc_session::parse::ParseSess;
use rustc_span::hygiene::AstPass;
use rustc_span::symbol::{kw, sym};
use rustc_span::{Span, DUMMY_SP};
@ -9,9 +11,7 @@ use smallvec::smallvec;
use syntax::ast::{self, Ident};
use syntax::attr;
use syntax::expand::is_proc_macro_attr;
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::sess::ParseSess;
use syntax::visit::{self, Visitor};
struct ProcMacroDerive {

View file

@ -1,3 +1,4 @@
use rustc_ast_pretty::pprust;
use rustc_expand::base::{self, *};
use rustc_expand::panictry;
use rustc_parse::{self, new_sub_parser_from_file, parser::Parser, DirectoryOwnership};
@ -5,7 +6,6 @@ use rustc_session::lint::builtin::INCOMPLETE_INCLUDE;
use rustc_span::symbol::Symbol;
use rustc_span::{self, Pos, Span};
use syntax::ast;
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token;
use syntax::tokenstream::TokenStream;

View file

@ -1,11 +1,11 @@
use rustc_expand::base::{ExtCtxt, Resolver};
use rustc_expand::expand::ExpansionConfig;
use rustc_session::parse::ParseSess;
use rustc_span::edition::Edition;
use rustc_span::hygiene::AstPass;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::DUMMY_SP;
use syntax::ptr::P;
use syntax::sess::ParseSess;
use syntax::{ast, attr};
pub fn inject(

View file

@ -2,13 +2,13 @@
/// Ideally, this code would be in libtest but for efficiency and error messages it lives here.
use crate::util::check_builtin_macro_attribute;
use rustc_ast_pretty::pprust;
use rustc_expand::base::*;
use rustc_span::source_map::respan;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
use syntax::ast;
use syntax::attr;
use syntax::print::pprust;
use std::iter;

View file

@ -4,6 +4,7 @@ use log::debug;
use rustc_expand::base::{ExtCtxt, Resolver};
use rustc_expand::expand::{AstFragment, ExpansionConfig};
use rustc_feature::Features;
use rustc_session::parse::ParseSess;
use rustc_span::hygiene::{AstPass, SyntaxContext, Transparency};
use rustc_span::source_map::respan;
use rustc_span::symbol::{sym, Symbol};
@ -15,7 +16,6 @@ use syntax::attr;
use syntax::entry::{self, EntryPointType};
use syntax::mut_visit::{ExpectOne, *};
use syntax::ptr::P;
use syntax::sess::ParseSess;
use std::{iter, mem};

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

@ -1723,7 +1723,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

@ -14,6 +14,7 @@ lazy_static = "1.0"
log = "0.4"
env_logger = { version = "0.7", default-features = false }
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_target = { path = "../librustc_target" }
rustc_lint = { path = "../librustc_lint" }
rustc_data_structures = { path = "../librustc_data_structures" }

View file

@ -5,14 +5,13 @@ use rustc::session::config::{Input, PpMode, PpSourceMode};
use rustc::session::Session;
use rustc::ty::{self, TyCtxt};
use rustc::util::common::ErrorReported;
use rustc_ast_pretty::pprust;
use rustc_hir as hir;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::print as pprust_hir;
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
use rustc_span::FileName;
use syntax::ast;
use syntax::print::pprust;
use std::cell::Cell;
use std::fs::File;
@ -392,14 +391,16 @@ pub fn print_after_parsing(
call_with_pp_support(&s, sess, None, move |annotation| {
debug!("pretty printing source code {:?}", s);
let sess = annotation.sess();
let parse = &sess.parse_sess;
*out = pprust::print_crate(
sess.source_map(),
&sess.parse_sess,
krate,
src_name,
src,
annotation.pp_ann(),
false,
parse.edition,
parse.injected_crate_name.try_get().is_some(),
)
})
} else {
@ -432,14 +433,16 @@ pub fn print_after_hir_lowering<'tcx>(
call_with_pp_support(&s, tcx.sess, Some(tcx), move |annotation| {
debug!("pretty printing source code {:?}", s);
let sess = annotation.sess();
let parse = &sess.parse_sess;
*out = pprust::print_crate(
sess.source_map(),
&sess.parse_sess,
krate,
src_name,
src,
annotation.pp_ann(),
true,
parse.edition,
parse.injected_crate_name.try_get().is_some(),
)
})
}
@ -449,14 +452,8 @@ pub fn print_after_hir_lowering<'tcx>(
call_with_pp_support_hir(&s, tcx, move |annotation, krate| {
debug!("pretty printing source code {:?}", s);
let sess = annotation.sess();
*out = pprust_hir::print_crate(
sess.source_map(),
&sess.parse_sess,
krate,
src_name,
src,
annotation.pp_ann(),
)
let cm = sess.source_map();
*out = pprust_hir::print_crate(cm, krate, src_name, src, annotation.pp_ann())
})
}

View file

@ -14,7 +14,9 @@ doctest = false
rustc_serialize = { path = "../libserialize", package = "serialize" }
log = "0.4"
rustc_span = { path = "../librustc_span" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
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,9 +1,11 @@
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};
use rustc_parse::{self, parser, DirectoryOwnership, MACRO_ARGUMENTS};
use rustc_session::parse::ParseSess;
use rustc_span::edition::Edition;
use rustc_span::hygiene::{AstPass, ExpnData, ExpnId, ExpnKind};
use rustc_span::source_map::SourceMap;
@ -11,10 +13,8 @@ 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;
use syntax::token;
use syntax::tokenstream::{self, TokenStream};
use syntax::visit::Visitor;
@ -62,7 +62,7 @@ impl HasAttrs for Annotatable {
}
}
fn visit_attrs<F: FnOnce(&mut Vec<Attribute>)>(&mut self, f: F) {
fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec<Attribute>)) {
match self {
Annotatable::Item(item) => item.visit_attrs(f),
Annotatable::TraitItem(trait_item) => trait_item.visit_attrs(f),

View file

@ -5,6 +5,8 @@ use crate::mbe::macro_rules::annotate_err_with_kind;
use crate::placeholders::{placeholder, PlaceholderExpander};
use crate::proc_macro::collect_derives;
use rustc_ast_pretty::pprust;
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;
@ -12,16 +14,14 @@ use rustc_parse::configure;
use rustc_parse::parser::Parser;
use rustc_parse::validate_attr;
use rustc_parse::DirectoryOwnership;
use rustc_session::parse::{feature_err, ParseSess};
use rustc_span::source_map::respan;
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;
use syntax::sess::{feature_err, ParseSess};
use syntax::token;
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::util::map_in_place::MapInPlace;
@ -1671,7 +1671,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
}
let meta = attr::mk_list_item(Ident::with_dummy_span(sym::doc), items);
*at = attr::Attribute {
*at = ast::Attribute {
kind: ast::AttrKind::Normal(AttrItem {
path: meta.path,
args: meta.kind.mac_args(meta.span),

View file

@ -76,13 +76,13 @@ use TokenTreeOrTokenTreeSlice::*;
use crate::mbe::{self, TokenTree};
use rustc_ast_pretty::pprust;
use rustc_parse::parser::{FollowedByType, Parser, PathStyle};
use rustc_parse::Directory;
use rustc_session::parse::ParseSess;
use rustc_span::symbol::{kw, sym, Symbol};
use syntax::ast::{Ident, Name};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::sess::ParseSess;
use syntax::token::{self, DocComment, Nonterminal, Token};
use syntax::tokenstream::TokenStream;

View file

@ -8,20 +8,20 @@ use crate::mbe::macro_parser::{Error, Failure, Success};
use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedParseResult};
use crate::mbe::transcribe::transcribe;
use rustc_ast_pretty::pprust;
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};
use rustc_feature::Features;
use rustc_parse::parser::Parser;
use rustc_parse::Directory;
use rustc_session::parse::ParseSess;
use rustc_span::edition::Edition;
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::*};
use syntax::tokenstream::{DelimSpan, TokenStream};

View file

@ -1,10 +1,10 @@
use crate::mbe::macro_parser;
use crate::mbe::{Delimited, KleeneOp, KleeneToken, SequenceRepetition, TokenTree};
use rustc_ast_pretty::pprust;
use rustc_session::parse::ParseSess;
use rustc_span::symbol::kw;
use syntax::ast;
use syntax::print::pprust;
use syntax::sess::ParseSess;
use syntax::token::{self, Token};
use syntax::tokenstream;

View file

@ -1,8 +1,8 @@
use crate::tests::{matches_codepattern, string_to_crate};
use rustc_ast_pretty::pprust;
use syntax::ast::{self, Ident};
use syntax::mut_visit::{self, MutVisitor};
use syntax::print::pprust;
use syntax::with_default_globals;
// This version doesn't care about getting comments or doc-strings in.

View file

@ -1,10 +1,10 @@
use rustc_data_structures::sync::Lrc;
use rustc_errors::{emitter::EmitterWriter, Handler};
use rustc_parse::lexer::StringReader;
use rustc_session::parse::ParseSess;
use rustc_span::source_map::{FilePathMapping, SourceMap};
use rustc_span::symbol::Symbol;
use rustc_span::{BytePos, Span};
use syntax::sess::ParseSess;
use syntax::token::{self, Token, TokenKind};
use syntax::util::comments::is_doc_comment;
use syntax::with_default_globals;

View file

@ -1,14 +1,14 @@
use crate::tests::{matches_codepattern, string_to_stream, with_error_checking_parse};
use rustc_ast_pretty::pprust::item_to_string;
use rustc_errors::PResult;
use rustc_parse::new_parser_from_source_str;
use rustc_session::parse::ParseSess;
use rustc_span::source_map::FilePathMapping;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{BytePos, FileName, Pos, Span};
use syntax::ast::{self, Name, PatKind};
use syntax::print::pprust::item_to_string;
use syntax::ptr::P;
use syntax::sess::ParseSess;
use syntax::token::{self, Token};
use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree};
use syntax::visit;

View file

@ -1,14 +1,14 @@
use crate::base::ExtCtxt;
use rustc_ast_pretty::pprust;
use rustc_data_structures::sync::Lrc;
use rustc_errors::Diagnostic;
use rustc_parse::lexer::nfc_normalize;
use rustc_parse::{nt_to_tokenstream, parse_stream_from_source_str};
use rustc_session::parse::ParseSess;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{BytePos, FileName, MultiSpan, Pos, SourceFile, Span};
use syntax::ast;
use syntax::print::pprust;
use syntax::sess::ParseSess;
use syntax::token;
use syntax::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream, TreeAndJoint};
use syntax::util::comments;

View file

@ -1,8 +1,8 @@
use rustc_parse::{new_parser_from_source_str, parser::Parser, source_file_to_stream};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::{FilePathMapping, SourceMap};
use rustc_span::{BytePos, MultiSpan, Span};
use syntax::ast;
use syntax::sess::ParseSess;
use syntax::tokenstream::TokenStream;
use syntax::with_default_globals;

View file

@ -10,6 +10,7 @@ path = "lib.rs"
doctest = false
[dependencies]
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_target = { path = "../librustc_target" }
rustc_macros = { path = "../librustc_macros" }
rustc_data_structures = { path = "../librustc_data_structures" }
@ -17,6 +18,5 @@ rustc_index = { path = "../librustc_index" }
rustc_span = { path = "../librustc_span" }
rustc_errors = { path = "../librustc_errors" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
rustc_session = { path = "../librustc_session" }
syntax = { path = "../libsyntax" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }

View file

@ -12,21 +12,22 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
use rustc_errors::FatalError;
use rustc_macros::HashStable_Generic;
use rustc_session::node_id::NodeMap;
use rustc_span::source_map::{SourceMap, Spanned};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{MultiSpan, Span, DUMMY_SP};
use rustc_target::spec::abi::Abi;
use smallvec::SmallVec;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt;
use syntax::ast::{self, AsmDialect, CrateSugar, Ident, Name, NodeId};
use syntax::ast::{AttrVec, Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, UintTy};
pub use syntax::ast::{BorrowKind, ImplPolarity, IsAuto};
pub use syntax::ast::{CaptureBy, Constness, Movability, Mutability, Unsafety};
use syntax::node_id::NodeMap;
use syntax::tokenstream::TokenStream;
use syntax::util::parser::ExprPrecedence;
use smallvec::SmallVec;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt;
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, HashStable_Generic)]
pub struct Lifetime {
pub hir_id: HirId,

View file

@ -1,12 +1,11 @@
use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent};
use rustc_ast_pretty::pp::{self, Breaks};
use rustc_ast_pretty::pprust::{self, Comments, PrintState};
use rustc_span::source_map::{SourceMap, Spanned};
use rustc_span::symbol::kw;
use rustc_span::{self, BytePos, FileName};
use rustc_target::spec::abi::Abi;
use syntax::ast;
use syntax::print::pp::Breaks::{Consistent, Inconsistent};
use syntax::print::pp::{self, Breaks};
use syntax::print::pprust::{self, Comments, PrintState};
use syntax::sess::ParseSess;
use syntax::util::parser::{self, AssocOp, Fixity};
use crate::hir;
@ -142,13 +141,12 @@ pub const INDENT_UNIT: usize = 4;
/// it can scan the input text for comments to copy forward.
pub fn print_crate<'a>(
cm: &'a SourceMap,
sess: &ParseSess,
krate: &hir::Crate<'_>,
filename: FileName,
input: String,
ann: &'a dyn PpAnn,
) -> String {
let mut s = State::new_from_input(cm, sess, filename, input, ann);
let mut s = State::new_from_input(cm, filename, input, ann);
// When printing the AST, we sometimes need to inject `#[no_std]` here.
// Since you can't compile the HIR, it's not necessary.
@ -161,12 +159,11 @@ pub fn print_crate<'a>(
impl<'a> State<'a> {
pub fn new_from_input(
cm: &'a SourceMap,
sess: &ParseSess,
filename: FileName,
input: String,
ann: &'a dyn PpAnn,
) -> State<'a> {
State { s: pp::mk_printer(), comments: Some(Comments::new(cm, sess, filename, input)), ann }
State { s: pp::mk_printer(), comments: Some(Comments::new(cm, filename, input)), ann }
}
}

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

@ -14,13 +14,13 @@ use rustc_data_structures::OnDrop;
use rustc_errors::registry::Registry;
use rustc_lint::LintStore;
use rustc_parse::new_parser_from_source_str;
use rustc_session::parse::{CrateConfig, ParseSess};
use rustc_span::edition;
use rustc_span::source_map::{FileLoader, FileName, SourceMap};
use std::path::PathBuf;
use std::result;
use std::sync::{Arc, Mutex};
use syntax::ast::{self, MetaItemKind};
use syntax::sess::ParseSess;
use syntax::ast::MetaItemKind;
use syntax::token;
pub type Result<T> = result::Result<T, ErrorReported>;
@ -106,7 +106,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
error!(r#"expected `key` or `key="value"`"#);
})
.collect::<ast::CrateConfig>();
.collect::<CrateConfig>();
cfg.into_iter().map(|(a, b)| (a.to_string(), b.map(|b| b.to_string()))).collect()
})
}

View file

@ -40,7 +40,6 @@ use rustc_span::FileName;
use rustc_traits;
use rustc_typeck as typeck;
use syntax::mut_visit::MutVisitor;
use syntax::util::node_count::NodeCounter;
use syntax::{self, ast, visit};
use rustc_serialize::json;
@ -83,7 +82,7 @@ pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> {
}
fn count_nodes(krate: &ast::Crate) -> usize {
let mut counter = NodeCounter::new();
let mut counter = rustc_ast_passes::node_count::NodeCounter::new();
visit::walk_crate(&mut counter, krate);
counter.count
}

View file

@ -14,6 +14,7 @@ use rustc_resolve::{self, Resolver};
use rustc_session as session;
use rustc_session::config::{ErrorOutputType, Input, OutputFilenames};
use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer};
use rustc_session::parse::CrateConfig;
use rustc_session::CrateDisambiguator;
use rustc_session::{config, early_error, filesearch, DiagnosticOutput, Session};
use rustc_span::edition::Edition;
@ -32,7 +33,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.).
@ -40,7 +41,7 @@ use syntax::{self, ast, attr};
/// This is performed by checking whether a whitelisted set of
/// features is available on the target machine, by querying LLVM.
pub fn add_configuration(
cfg: &mut ast::CrateConfig,
cfg: &mut CrateConfig,
sess: &Session,
codegen_backend: &dyn CodegenBackend,
) {
@ -547,7 +548,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,8 @@ path = "lib.rs"
log = "0.4"
unicode-security = "0.0.2"
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_errors = { path = "../librustc_errors" }
rustc_hir = { path = "../librustc_hir" }
rustc_target = { path = "../librustc_target" }

View file

@ -25,6 +25,7 @@ use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}
use rustc::hir::map::Map;
use rustc::traits::misc::can_type_implement_copy;
use rustc::ty::{self, layout::VariantIdx, Ty, TyCtxt};
use rustc_ast_pretty::pprust::{self, expr_to_string};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_feature::Stability;
@ -41,7 +42,6 @@ use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{BytePos, Span};
use syntax::ast::{self, Expr};
use syntax::attr::{self, HasAttrs};
use syntax::print::pprust::{self, expr_to_string};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::visit::FnKind;

View file

@ -1,23 +1,22 @@
use crate::context::{CheckLintNameResult, LintStore};
use crate::late::unerased_lint_store;
use rustc::hir::map::Map;
use rustc::lint::struct_lint_level;
use rustc::lint::{LintLevelMap, LintLevelSets, LintSet, LintSource};
use rustc::lint::{struct_lint_level, LintLevelMap, LintLevelSets, LintSet, LintSource};
use rustc::ty::query::Providers;
use rustc::ty::TyCtxt;
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
use rustc_hir::hir_id::HirId;
use rustc_hir::intravisit;
use rustc_hir::{intravisit, HirId};
use rustc_session::lint::{builtin, Level, Lint};
use rustc_session::parse::feature_err;
use rustc_session::Session;
use rustc_span::{sym, MultiSpan, Symbol};
use rustc_span::source_map::MultiSpan;
use rustc_span::symbol::{sym, Symbol};
use syntax::ast;
use syntax::attr;
use syntax::print::pprust;
use syntax::sess::feature_err;
use syntax::unwrap_or;
use std::cmp;

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

@ -1,6 +1,7 @@
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
use rustc::ty::adjustment;
use rustc::ty::{self, Ty};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{pluralize, Applicability};
use rustc_feature::{AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
@ -13,7 +14,6 @@ use rustc_span::symbol::{kw, sym};
use rustc_span::{BytePos, Span};
use syntax::ast;
use syntax::attr;
use syntax::print::pprust;
use syntax::util::parser;
use log::debug;

View file

@ -15,6 +15,8 @@ log = "0.4"
memmap = "0.7"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
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

@ -1236,7 +1236,7 @@ impl EncodeContext<'tcx> {
/// Serialize the text of exported macros
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef<'_>) {
use syntax::print::pprust;
use rustc_ast_pretty::pprust;
let def_id = self.tcx.hir().local_def_id(macro_def.hir_id);
record!(self.per_def.kind[def_id] <- EntryKind::MacroDef(self.lazy(MacroDef {
body: pprust::tts_to_string(macro_def.body.clone()),

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,8 @@ log = "0.4"
log_settings = "0.1.1"
polonius-engine = "0.11.0"
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
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

@ -1,6 +1,6 @@
use rustc_ast_pretty::pprust;
use rustc_span::symbol::{sym, Symbol};
use syntax::ast::{self, MetaItem};
use syntax::print::pprust;
use rustc_data_structures::work_queue::WorkQueue;
use rustc_index::bit_set::{BitSet, HybridBitSet};

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

@ -1,11 +1,12 @@
use rustc::mir::*;
use rustc::ty::{self, adjustment::PointerCast, Predicate, Ty, TyCtxt};
use rustc_attr as attr;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
use std::borrow::Cow;
use syntax::{ast, attr};
use syntax::ast;
type McfResult = Result<(), (Span, Cow<'static, str>)>;

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,8 @@ doctest = false
[dependencies]
bitflags = "1.0"
log = "0.4"
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
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,21 +9,21 @@
//! [#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};
use rustc_feature::{
ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES, STABLE_REMOVED_FEATURES,
};
use rustc_session::parse::{feature_err, ParseSess};
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;
use syntax::sess::{feature_err, ParseSess};
use syntax::util::map_in_place::MapInPlace;
use smallvec::SmallVec;

View file

@ -2,9 +2,9 @@ use rustc_data_structures::sync::Lrc;
use rustc_errors::{DiagnosticBuilder, FatalError};
use rustc_lexer::unescape;
use rustc_lexer::Base;
use rustc_session::parse::ParseSess;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{BytePos, Pos, Span};
use syntax::sess::ParseSess;
use syntax::token::{self, Token, TokenKind};
use syntax::util::comments;

View file

@ -1,9 +1,9 @@
use super::{StringReader, UnmatchedBrace};
use rustc_ast_pretty::pprust::token_to_string;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::PResult;
use rustc_span::Span;
use syntax::print::pprust::token_to_string;
use syntax::token::{self, Token};
use syntax::tokenstream::{
DelimSpan,

View file

@ -4,15 +4,14 @@
#![feature(crate_visibility_modifier)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
use syntax::ast;
use syntax::print::pprust;
use syntax::sess::ParseSess;
use syntax::token::{self, Nonterminal};
use syntax::tokenstream::{self, TokenStream, TokenTree};
use rustc_ast_pretty::pprust;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{Diagnostic, FatalError, Level, PResult};
use rustc_session::parse::ParseSess;
use rustc_span::{FileName, SourceFile, Span};
use syntax::ast;
use syntax::token::{self, Nonterminal};
use syntax::tokenstream::{self, TokenStream, TokenTree};
use std::borrow::Cow;
use std::path::Path;

View file

@ -1,9 +1,9 @@
use super::{Parser, PathStyle, TokenType};
use rustc_ast_pretty::pprust;
use rustc_errors::PResult;
use rustc_span::{Span, Symbol};
use syntax::ast;
use syntax::attr;
use syntax::print::pprust;
use syntax::token::{self, Nonterminal};
use syntax::util::comments;

View file

@ -1,5 +1,6 @@
use super::{BlockMode, Parser, PathStyle, SemiColonMode, SeqSep, TokenExpectType, TokenType};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{pluralize, struct_span_err};
use rustc_errors::{Applicability, DiagnosticBuilder, Handler, PResult};
@ -10,7 +11,6 @@ use syntax::ast::{
self, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item, Param,
};
use syntax::ast::{AttrVec, ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, token_can_begin_expr, TokenKind};
use syntax::util::parser::AssocOp;

View file

@ -3,6 +3,7 @@ use super::{BlockMode, Parser, PathStyle, PrevTokenKind, Restrictions, TokenType
use super::{SemiColonMode, SeqSep, TokenExpectType};
use crate::maybe_recover_from_interpolated_ty_qpath;
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, PResult};
use rustc_span::source_map::{self, Span, Spanned};
use rustc_span::symbol::{kw, sym, Symbol};
@ -12,7 +13,6 @@ use syntax::ast::{
AnonConst, BinOp, BinOpKind, FnDecl, FunctionRetTy, Mac, Param, Ty, TyKind, UnOp,
};
use syntax::ast::{Arm, BlockCheckMode, Expr, ExprKind, IsAsync, Label, Movability, RangeLimits};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, Token, TokenKind};
use syntax::util::classify;

View file

@ -3,6 +3,7 @@ use super::{FollowedByType, Parser, PathStyle};
use crate::maybe_whole;
use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, PResult, StashKey};
use rustc_span::source_map::{self, respan, Span};
use rustc_span::symbol::{kw, sym, Symbol};
@ -13,7 +14,6 @@ use syntax::ast::{BindingMode, Block, FnDecl, FnSig, Mac, MacArgs, MacDelimiter,
use syntax::ast::{Constness, Defaultness, Extern, IsAsync, IsAuto, PathSegment, StrLit, Unsafety};
use syntax::ast::{EnumDef, Generics, StructField, TraitRef, Ty, TyKind, Variant, VariantData};
use syntax::ast::{FnHeader, ForeignItem, ForeignItemKind, Mutability, Visibility, VisibilityKind};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token;
use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree};

View file

@ -16,15 +16,15 @@ use crate::lexer::UnmatchedBrace;
use crate::{Directory, DirectoryOwnership};
use log::debug;
use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, FatalError, PResult};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::respan;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{BytePos, FileName, Span, DUMMY_SP};
use syntax::ast::{self, AttrStyle, AttrVec, CrateSugar, Extern, Ident, Unsafety, DUMMY_NODE_ID};
use syntax::ast::{IsAsync, MacArgs, MacDelimiter, Mutability, StrLit, Visibility, VisibilityKind};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::sess::ParseSess;
use syntax::token::{self, DelimToken, Token, TokenKind};
use syntax::tokenstream::{self, DelimSpan, TokenStream, TokenTree, TreeAndJoint};
use syntax::util::comments::{doc_comment_style, strip_doc_comment_decoration};

View file

@ -1,12 +1,12 @@
use super::{Parser, PathStyle};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, PResult};
use rustc_span::source_map::{respan, Span, Spanned};
use rustc_span::symbol::{kw, sym};
use syntax::ast::{self, AttrVec, Attribute, FieldPat, Mac, Pat, PatKind, RangeEnd, RangeSyntax};
use syntax::ast::{BindingMode, Expr, ExprKind, Ident, Mutability, Path, QSelf};
use syntax::mut_visit::{noop_visit_mac, noop_visit_pat, MutVisitor};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token;

Some files were not shown because too many files have changed in this diff Show more