diff --git a/Cargo.lock b/Cargo.lock index 0a76aabc3a312..7ed954b705c74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3097,6 +3097,7 @@ dependencies = [ "rustc-rayon", "rustc-rayon-core", "rustc_apfloat", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3362,6 +3363,7 @@ version = "0.0.0" dependencies = [ "log", "rustc", + "rustc_ast_pretty", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -3378,6 +3380,8 @@ name = "rustc_ast_passes" version = "0.0.0" dependencies = [ "log", + "rustc_ast_pretty", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3387,12 +3391,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", @@ -3415,6 +3447,7 @@ dependencies = [ "log", "rustc", "rustc-demangle", + "rustc_attr", "rustc_codegen_ssa", "rustc_codegen_utils", "rustc_data_structures", @@ -3445,6 +3478,7 @@ dependencies = [ "num_cpus", "rustc", "rustc_apfloat", + "rustc_attr", "rustc_codegen_utils", "rustc_data_structures", "rustc_errors", @@ -3509,6 +3543,7 @@ dependencies = [ "lazy_static 1.3.0", "log", "rustc", + "rustc_ast_pretty", "rustc_codegen_utils", "rustc_data_structures", "rustc_error_codes", @@ -3555,6 +3590,8 @@ version = "0.0.0" dependencies = [ "log", "rustc_ast_passes", + "rustc_ast_pretty", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3584,11 +3621,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", @@ -3631,6 +3668,7 @@ dependencies = [ "rustc-rayon", "rustc_ast_lowering", "rustc_ast_passes", + "rustc_attr", "rustc_builtin_macros", "rustc_codegen_llvm", "rustc_codegen_ssa", @@ -3675,6 +3713,8 @@ version = "0.0.0" dependencies = [ "log", "rustc", + "rustc_ast_pretty", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3715,6 +3755,8 @@ dependencies = [ "log", "memmap", "rustc", + "rustc_ast_pretty", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_expand", @@ -3742,6 +3784,8 @@ dependencies = [ "polonius-engine", "rustc", "rustc_apfloat", + "rustc_ast_pretty", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -3764,6 +3808,7 @@ dependencies = [ "log", "rustc", "rustc_apfloat", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -3783,6 +3828,8 @@ version = "0.0.0" dependencies = [ "bitflags", "log", + "rustc_ast_pretty", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3800,6 +3847,7 @@ version = "0.0.0" dependencies = [ "log", "rustc", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -3830,6 +3878,7 @@ version = "0.0.0" dependencies = [ "log", "rustc", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -3847,6 +3896,8 @@ dependencies = [ "log", "rustc", "rustc_ast_lowering", + "rustc_ast_pretty", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_expand", @@ -3867,6 +3918,7 @@ dependencies = [ "rls-data", "rls-span", "rustc", + "rustc_ast_pretty", "rustc_codegen_utils", "rustc_data_structures", "rustc_hir", @@ -3890,6 +3942,7 @@ dependencies = [ "rustc_span", "rustc_target", "serialize", + "syntax", ] [[package]] @@ -3964,6 +4017,7 @@ dependencies = [ "arena", "log", "rustc", + "rustc_attr", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -4484,12 +4538,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", diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 1fbdd50a51133..2101ef27f9d42 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -104,7 +104,7 @@ Usage: x.py [options] [...] Subcommands: build Compile either the compiler or libraries check Compile either the compiler or libraries, using cargo check - clippy Run clippy + clippy Run clippy (uses rustup/cargo-installed clippy binary) fix Run cargo fix fmt Run rustfmt test Build and run some test suites diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile index 546e73e33d7f3..2a68a25be21b3 100644 --- a/src/ci/docker/dist-various-1/Dockerfile +++ b/src/ci/docker/dist-various-1/Dockerfile @@ -160,6 +160,7 @@ ENV TARGETS=$TARGETS,armebv7r-none-eabihf ENV TARGETS=$TARGETS,armv7r-none-eabi ENV TARGETS=$TARGETS,armv7r-none-eabihf ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf +ENV TARGETS=$TARGETS,armv7a-none-eabi # riscv targets currently do not need a C compiler, as compiler_builtins # doesn't currently have it enabled, and the riscv gcc compiler is not @@ -173,6 +174,10 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ CC_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \ AR_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar \ CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \ + CC_armv7a_none_eabi=arm-none-eabi-gcc \ + CC_armv7a_none_eabihf=arm-none-eabi-gcc \ + CFLAGS_armv7a_none_eabi=-march=armv7-a \ + CFLAGS_armv7a_none_eabihf=-march=armv7-a+vfpv3 \ CC_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-gcc \ AR_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-ar \ CXX_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-g++ \ diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index b65635be54a3f..782c6879ac58f 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -21,6 +21,7 @@ rustc-rayon = "0.3.0" rustc-rayon-core = "0.3.0" polonius-engine = "0.11.0" rustc_apfloat = { path = "../librustc_apfloat" } +rustc_attr = { path = "../librustc_attr" } rustc_feature = { path = "../librustc_feature" } rustc_hir = { path = "../librustc_hir" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index ac2d7a9a8dc2a..048c1f026be82 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -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; diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 8961f7cd4bc95..061b82ebb430e 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -3,12 +3,12 @@ use crate::hir::map::DefPathHash; use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext}; +use rustc_attr as attr; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX}; use smallvec::SmallVec; use std::mem; -use syntax::attr; impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> { #[inline] diff --git a/src/librustc/middle/codegen_fn_attrs.rs b/src/librustc/middle/codegen_fn_attrs.rs index 3b109f2fea687..9f8c20208616b 100644 --- a/src/librustc/middle/codegen_fn_attrs.rs +++ b/src/librustc/middle/codegen_fn_attrs.rs @@ -1,6 +1,6 @@ use crate::mir::mono::Linkage; +use rustc_attr::{InlineAttr, OptimizeAttr}; use rustc_span::symbol::Symbol; -use syntax::attr::{InlineAttr, OptimizeAttr}; #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub struct CodegenFnAttrs { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 1176ffc79d26d..7cbe77b9e82f0 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -5,6 +5,7 @@ pub use self::StabilityLevel::*; use crate::session::{DiagnosticMessageId, Session}; use crate::ty::{self, TyCtxt}; +use rustc_attr::{self as attr, ConstStability, Deprecation, RustcDeprecation, Stability}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_feature::GateIssue; @@ -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, 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) -> 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) diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index 51ce575e51f3b..ee8412ccbe37a 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -3,6 +3,7 @@ use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext}; use crate::session::config::OptLevel; use crate::ty::print::obsolete::DefPathBasedNames; use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt}; +use rustc_attr::InlineAttr; use rustc_data_structures::base_n; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -12,7 +13,6 @@ use rustc_span::source_map::Span; use rustc_span::symbol::Symbol; use std::fmt; use std::hash::Hash; -use syntax::attr::InlineAttr; /// Describes how a monomorphization will be instantiated in object files. #[derive(PartialEq)] diff --git a/src/librustc/traits/error_reporting/mod.rs b/src/librustc/traits/error_reporting/mod.rs index d1c369d0abbf3..cdb50779e00cc 100644 --- a/src/librustc/traits/error_reporting/mod.rs +++ b/src/librustc/traits/error_reporting/mod.rs @@ -919,17 +919,29 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { report_object_safety_error(self.tcx, span, did, violations) } - // already reported in the query - ConstEvalFailure(err) => { - if let ErrorHandled::TooGeneric = err { - // Silence this error, as it can be produced during intermediate steps - // when a constant is not yet able to be evaluated (but will be later). - return; - } - self.tcx.sess.delay_span_bug( - span, - &format!("constant in type had an ignored error: {:?}", err), - ); + ConstEvalFailure(ErrorHandled::TooGeneric) => { + // In this instance, we have a const expression containing an unevaluated + // generic parameter. We have no idea whether this expression is valid or + // not (e.g. it might result in an error), but we don't want to just assume + // that it's okay, because that might result in post-monomorphisation time + // errors. The onus is really on the caller to provide values that it can + // prove are well-formed. + let mut err = self + .tcx + .sess + .struct_span_err(span, "constant expression depends on a generic parameter"); + // FIXME(const_generics): we should suggest to the user how they can resolve this + // issue. However, this is currently not actually possible + // (see https://github.com/rust-lang/rust/issues/66962#issuecomment-575907083). + err.note("this may fail depending on what value the parameter takes"); + err + } + + // Already reported in the query. + ConstEvalFailure(ErrorHandled::Reported) => { + self.tcx + .sess + .delay_span_bug(span, &format!("constant in type had an ignored error")); return; } diff --git a/src/librustc/traits/error_reporting/on_unimplemented.rs b/src/librustc/traits/error_reporting/on_unimplemented.rs index 9f3fc91548b21..2ba12baaf6d6e 100644 --- a/src/librustc/traits/error_reporting/on_unimplemented.rs +++ b/src/librustc/traits/error_reporting/on_unimplemented.rs @@ -59,31 +59,45 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { fn describe_enclosure(&self, hir_id: hir::HirId) -> Option<&'static str> { let hir = &self.tcx.hir(); let node = hir.find(hir_id)?; - if let hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. }) = &node { - self.describe_generator(*body_id).or_else(|| { + match &node { + hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. }) => { + self.describe_generator(*body_id).or_else(|| { + Some(if let hir::FnHeader { asyncness: hir::IsAsync::Async, .. } = sig.header { + "an async function" + } else { + "a function" + }) + }) + } + hir::Node::TraitItem(hir::TraitItem { + kind: hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)), + .. + }) => self.describe_generator(*body_id).or_else(|| Some("a trait method")), + hir::Node::ImplItem(hir::ImplItem { + kind: hir::ImplItemKind::Method(sig, body_id), + .. + }) => self.describe_generator(*body_id).or_else(|| { Some(if let hir::FnHeader { asyncness: hir::IsAsync::Async, .. } = sig.header { - "an async function" + "an async method" } else { - "a function" + "a method" }) - }) - } else if let hir::Node::Expr(hir::Expr { - kind: hir::ExprKind::Closure(_is_move, _, body_id, _, gen_movability), - .. - }) = &node - { - self.describe_generator(*body_id).or_else(|| { + }), + hir::Node::Expr(hir::Expr { + kind: hir::ExprKind::Closure(_is_move, _, body_id, _, gen_movability), + .. + }) => self.describe_generator(*body_id).or_else(|| { Some(if gen_movability.is_some() { "an async closure" } else { "a closure" }) - }) - } else if let hir::Node::Expr(hir::Expr { .. }) = &node { - let parent_hid = hir.get_parent_node(hir_id); - if parent_hid != hir_id { - return self.describe_enclosure(parent_hid); - } else { - None + }), + hir::Node::Expr(hir::Expr { .. }) => { + let parent_hid = hir.get_parent_node(hir_id); + if parent_hid != hir_id { + return self.describe_enclosure(parent_hid); + } else { + None + } } - } else { - None + _ => None, } } diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index 669ec5ccc9b98..ca824d40e381a 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -3,13 +3,13 @@ use fmt_macros::{Parser, Piece, Position}; use crate::ty::{self, GenericParamDefKind, TyCtxt}; use crate::util::common::ErrorReported; +use rustc_attr as attr; use rustc_data_structures::fx::FxHashMap; use rustc_errors::struct_span_err; use rustc_hir::def_id::DefId; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; use syntax::ast::{MetaItem, NestedMetaItem}; -use syntax::attr; #[derive(Clone, Debug)] pub struct OnUnimplementedFormatString(Symbol); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index a51f0f7f24c36..782a7413378ca 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -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, ()>; diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index acaa4eec9410d..bda42db40b0ae 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1,9 +1,9 @@ use crate::session::{self, DataTypeKind}; use crate::ty::{self, subst::SubstsRef, ReprOptions, Ty, TyCtxt, TypeFoldable}; +use rustc_attr as attr; use rustc_span::DUMMY_SP; use syntax::ast::{self, Ident, IntTy, UintTy}; -use syntax::attr; use std::cmp; use std::fmt; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 0470ab20dc464..65cb2c046c82f 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -26,6 +26,7 @@ use crate::ty::layout::VariantIdx; use crate::ty::subst::{InternalSubsts, Subst, SubstsRef}; use crate::ty::util::{Discr, IntTypeExt}; use crate::ty::walk::TypeWalker; +use rustc_attr as attr; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxIndexMap; @@ -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::*; diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 9091de55b7d8e..295562c7865bf 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -11,10 +11,10 @@ use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; +use rustc_attr::{SignedInt, UnsignedInt}; use rustc_span::symbol::{kw, Symbol}; use rustc_target::spec::abi::Abi; use syntax::ast; -use syntax::attr::{SignedInt, UnsignedInt}; use std::cell::Cell; use std::collections::BTreeMap; diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index dd8274dcf22a5..393125f278c03 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -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, ®istry))) }); diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 0f09a08b199f1..973cd81014616 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -49,6 +49,7 @@ use rustc_hir::{HirIdSet, ItemLocalId, TraitCandidate}; use rustc_index::vec::IndexVec; use rustc_target::spec::PanicStrategy; +use rustc_attr as attr; use rustc_span::symbol::Symbol; use rustc_span::{Span, DUMMY_SP}; use std::any::type_name; @@ -56,7 +57,6 @@ use std::borrow::Cow; use std::ops::Deref; use std::sync::Arc; use syntax::ast; -use syntax::attr; #[macro_use] mod plumbing; diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 8d22ac9dbbe97..4dfff85d53147 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -10,6 +10,7 @@ use crate::ty::TyKind::*; use crate::ty::{self, DefIdTree, GenericParamDefKind, Ty, TyCtxt, TypeFoldable}; use crate::util::common::ErrorReported; use rustc_apfloat::Float as _; +use rustc_attr::{self as attr, SignedInt, UnsignedInt}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_hir as hir; @@ -19,7 +20,6 @@ use rustc_macros::HashStable; use rustc_span::Span; use std::{cmp, fmt}; use syntax::ast; -use syntax::attr::{self, SignedInt, UnsignedInt}; #[derive(Copy, Clone, Debug)] pub struct Discr<'tcx> { diff --git a/src/librustc_ast_lowering/Cargo.toml b/src/librustc_ast_lowering/Cargo.toml index 4b786d6245fc4..f6ab60e199f33 100644 --- a/src/librustc_ast_lowering/Cargo.toml +++ b/src/librustc_ast_lowering/Cargo.toml @@ -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" } diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs index 2025d0c1c8e34..e27f2bdb8d25f 100644 --- a/src/librustc_ast_lowering/item.rs +++ b/src/librustc_ast_lowering/item.rs @@ -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; diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index 284ede3b4fa1a..c3e96a31e4001 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -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", diff --git a/src/librustc_ast_passes/Cargo.toml b/src/librustc_ast_passes/Cargo.toml index 25b1acebd2a08..01d2ac449b590 100644 --- a/src/librustc_ast_passes/Cargo.toml +++ b/src/librustc_ast_passes/Cargo.toml @@ -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" } diff --git a/src/librustc_ast_passes/ast_validation.rs b/src/librustc_ast_passes/ast_validation.rs index 152086bfce0ea..4bb55d6acddcd 100644 --- a/src/librustc_ast_passes/ast_validation.rs +++ b/src/librustc_ast_passes/ast_validation.rs @@ -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() { diff --git a/src/librustc_ast_passes/feature_gate.rs b/src/librustc_ast_passes/feature_gate.rs index 953127429d5aa..3b13ab354fdf9 100644 --- a/src/librustc_ast_passes/feature_gate.rs +++ b/src/librustc_ast_passes/feature_gate.rs @@ -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; diff --git a/src/librustc_ast_passes/lib.rs b/src/librustc_ast_passes/lib.rs index 5de45f4e1f365..b4d8ddccb041d 100644 --- a/src/librustc_ast_passes/lib.rs +++ b/src/librustc_ast_passes/lib.rs @@ -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; diff --git a/src/libsyntax/util/node_count.rs b/src/librustc_ast_passes/node_count.rs similarity index 98% rename from src/libsyntax/util/node_count.rs rename to src/librustc_ast_passes/node_count.rs index 39f978ce98c6c..9fe7238fcfc3e 100644 --- a/src/libsyntax/util/node_count.rs +++ b/src/librustc_ast_passes/node_count.rs @@ -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, diff --git a/src/librustc_ast_pretty/Cargo.toml b/src/librustc_ast_pretty/Cargo.toml new file mode 100644 index 0000000000000..2f7f804b62887 --- /dev/null +++ b/src/librustc_ast_pretty/Cargo.toml @@ -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" } diff --git a/src/libsyntax/print/helpers.rs b/src/librustc_ast_pretty/helpers.rs similarity index 95% rename from src/libsyntax/print/helpers.rs rename to src/librustc_ast_pretty/helpers.rs index 88942cb7fd60f..dce856df9c66a 100644 --- a/src/libsyntax/print/helpers.rs +++ b/src/librustc_ast_pretty/helpers.rs @@ -1,4 +1,4 @@ -use crate::print::pp::Printer; +use crate::pp::Printer; use std::borrow::Cow; impl Printer { diff --git a/src/librustc_ast_pretty/lib.rs b/src/librustc_ast_pretty/lib.rs new file mode 100644 index 0000000000000..bde5f4bb03d0d --- /dev/null +++ b/src/librustc_ast_pretty/lib.rs @@ -0,0 +1,7 @@ +#![feature(bool_to_option)] +#![feature(crate_visibility_modifier)] +#![recursion_limit = "256"] + +mod helpers; +pub mod pp; +pub mod pprust; diff --git a/src/libsyntax/print/pp.rs b/src/librustc_ast_pretty/pp.rs similarity index 100% rename from src/libsyntax/print/pp.rs rename to src/librustc_ast_pretty/pp.rs diff --git a/src/libsyntax/print/pprust.rs b/src/librustc_ast_pretty/pprust.rs similarity index 98% rename from src/libsyntax/print/pprust.rs rename to src/librustc_ast_pretty/pprust.rs index 3927e4f903011..00c19e0660cea 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/librustc_ast_pretty/pprust.rs @@ -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) -> 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); diff --git a/src/libsyntax/print/pprust/tests.rs b/src/librustc_ast_pretty/pprust/tests.rs similarity index 97% rename from src/libsyntax/print/pprust/tests.rs rename to src/librustc_ast_pretty/pprust/tests.rs index 3091e3155805b..279e6f518a71d 100644 --- a/src/libsyntax/print/pprust/tests.rs +++ b/src/librustc_ast_pretty/pprust/tests.rs @@ -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, diff --git a/src/librustc_attr/Cargo.toml b/src/librustc_attr/Cargo.toml new file mode 100644 index 0000000000000..83a5f41989b6c --- /dev/null +++ b/src/librustc_attr/Cargo.toml @@ -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" } diff --git a/src/libsyntax/attr/builtin.rs b/src/librustc_attr/builtin.rs similarity index 97% rename from src/libsyntax/attr/builtin.rs rename to src/librustc_attr/builtin.rs index 6cfe4f2de1e96..fd6b61c024a6c 100644 --- a/src/libsyntax/attr/builtin.rs +++ b/src/librustc_attr/builtin.rs @@ -1,16 +1,16 @@ //! Parsing and validation of builtin attributes -use super::{mark_used, MetaItemKind}; -use crate::ast::{self, Attribute, MetaItem, NestedMetaItem}; -use crate::print::pprust; -use crate::sess::{feature_err, ParseSess}; +use super::{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() @@ -1030,3 +1030,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 + '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 + })) +} diff --git a/src/librustc_attr/lib.rs b/src/librustc_attr/lib.rs new file mode 100644 index 0000000000000..d2ff167db88e5 --- /dev/null +++ b/src/librustc_attr/lib.rs @@ -0,0 +1,16 @@ +//! Functions and types dealing with attributes and meta items. +//! +//! FIXME(Centril): For now being, much of the logic is still in `syntax::attr`. +//! The goal is to move the definition of `MetaItem` and things that don't need to be in `syntax` +//! to this crate. + +mod builtin; + +pub use builtin::*; +pub use IntType::*; +pub use ReprAttr::*; +pub use StabilityLevel::*; + +pub use syntax::attr::*; + +pub(crate) use syntax::HashStableContext; diff --git a/src/librustc_builtin_macros/Cargo.toml b/src/librustc_builtin_macros/Cargo.toml index 3ce7f5d770ed1..b424ce432148f 100644 --- a/src/librustc_builtin_macros/Cargo.toml +++ b/src/librustc_builtin_macros/Cargo.toml @@ -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" } diff --git a/src/librustc_builtin_macros/assert.rs b/src/librustc_builtin_macros/assert.rs index a992b6e2662d2..3fc86a5469c2f 100644 --- a/src/librustc_builtin_macros/assert.rs +++ b/src/librustc_builtin_macros/assert.rs @@ -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}; diff --git a/src/librustc_builtin_macros/cfg.rs b/src/librustc_builtin_macros/cfg.rs index cee62a54f0088..c9a77ee0acd15 100644 --- a/src/librustc_builtin_macros/cfg.rs +++ b/src/librustc_builtin_macros/cfg.rs @@ -2,11 +2,11 @@ //! a literal `true` or `false` based on whether the given cfg matches the //! current compilation environment. +use rustc_attr as attr; use rustc_errors::DiagnosticBuilder; use rustc_expand::base::{self, *}; use rustc_span::Span; use syntax::ast; -use syntax::attr; use syntax::token; use syntax::tokenstream::TokenStream; diff --git a/src/librustc_builtin_macros/cmdline_attrs.rs b/src/librustc_builtin_macros/cmdline_attrs.rs index 2f7f7e73ac2ce..aa373d31e0609 100644 --- a/src/librustc_builtin_macros/cmdline_attrs.rs +++ b/src/librustc_builtin_macros/cmdline_attrs.rs @@ -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 { diff --git a/src/librustc_builtin_macros/deriving/generic/mod.rs b/src/librustc_builtin_macros/deriving/generic/mod.rs index f8918016c1b98..59c8306f20da0 100644 --- a/src/librustc_builtin_macros/deriving/generic/mod.rs +++ b/src/librustc_builtin_macros/deriving/generic/mod.rs @@ -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}; diff --git a/src/librustc_builtin_macros/log_syntax.rs b/src/librustc_builtin_macros/log_syntax.rs index 7c7fc286e0a5e..6d9bfbfd05f0a 100644 --- a/src/librustc_builtin_macros/log_syntax.rs +++ b/src/librustc_builtin_macros/log_syntax.rs @@ -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 { - 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) diff --git a/src/librustc_builtin_macros/proc_macro_harness.rs b/src/librustc_builtin_macros/proc_macro_harness.rs index ae70608505130..222456d8fe0d9 100644 --- a/src/librustc_builtin_macros/proc_macro_harness.rs +++ b/src/librustc_builtin_macros/proc_macro_harness.rs @@ -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 { diff --git a/src/librustc_builtin_macros/source_util.rs b/src/librustc_builtin_macros/source_util.rs index dc85a92d272c4..264223bafbcf9 100644 --- a/src/librustc_builtin_macros/source_util.rs +++ b/src/librustc_builtin_macros/source_util.rs @@ -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; diff --git a/src/librustc_builtin_macros/standard_library_imports.rs b/src/librustc_builtin_macros/standard_library_imports.rs index 0c982b21eee2c..6663eecbf5f4b 100644 --- a/src/librustc_builtin_macros/standard_library_imports.rs +++ b/src/librustc_builtin_macros/standard_library_imports.rs @@ -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( diff --git a/src/librustc_builtin_macros/test.rs b/src/librustc_builtin_macros/test.rs index 07715cdbcb5e9..2d6ff81aea8b8 100644 --- a/src/librustc_builtin_macros/test.rs +++ b/src/librustc_builtin_macros/test.rs @@ -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; diff --git a/src/librustc_builtin_macros/test_harness.rs b/src/librustc_builtin_macros/test_harness.rs index 17d180da6bfda..6a73f121c99bf 100644 --- a/src/librustc_builtin_macros/test_harness.rs +++ b/src/librustc_builtin_macros/test_harness.rs @@ -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}; diff --git a/src/librustc_codegen_llvm/Cargo.toml b/src/librustc_codegen_llvm/Cargo.toml index 3ff5495e29136..0f8e3ef589e68 100644 --- a/src/librustc_codegen_llvm/Cargo.toml +++ b/src/librustc_codegen_llvm/Cargo.toml @@ -17,6 +17,7 @@ libc = "0.2" log = "0.4" rustc = { path = "../librustc" } rustc-demangle = "0.1" +rustc_attr = { path = "../librustc_attr" } rustc_codegen_ssa = { path = "../librustc_codegen_ssa" } rustc_codegen_utils = { path = "../librustc_codegen_utils" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index 4ed4e8ac6efab..b01793483133a 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -21,7 +21,7 @@ use crate::attributes; use crate::llvm::AttributePlace::Function; use crate::llvm::{self, Attribute}; use crate::llvm_util; -pub use syntax::attr::{self, InlineAttr, OptimizeAttr}; +pub use rustc_attr::{self as attr, InlineAttr, OptimizeAttr}; use crate::context::CodegenCx; use crate::value::Value; diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml index 9f8b4e72a9cbf..8d767e5c2a04f 100644 --- a/src/librustc_codegen_ssa/Cargo.toml +++ b/src/librustc_codegen_ssa/Cargo.toml @@ -24,6 +24,7 @@ syntax = { path = "../libsyntax" } rustc_span = { path = "../librustc_span" } rustc = { path = "../librustc" } rustc_apfloat = { path = "../librustc_apfloat" } +rustc_attr = { path = "../librustc_attr" } rustc_codegen_utils = { path = "../librustc_codegen_utils" } rustc_data_structures = { path = "../librustc_data_structures"} rustc_errors = { path = "../librustc_errors" } diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index 53ee5996432ce..3c8b0a180e530 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -1719,7 +1719,7 @@ pub fn add_upstream_native_libraries( pub fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { match lib.cfg { - Some(ref cfg) => syntax::attr::cfg_matches(cfg, &sess.parse_sess, None), + Some(ref cfg) => rustc_attr::cfg_matches(cfg, &sess.parse_sess, None), None => true, } } diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index bd44b4a38fd58..d680e14bbbd5b 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc::middle::exported_symbols::{metadata_symbol_name, ExportedSymbol, SymbolExportLevel}; -use rustc::session::config; +use rustc::session::config::{self, Sanitizer}; use rustc::ty::query::Providers; use rustc::ty::subst::SubstsRef; use rustc::ty::Instance; @@ -206,6 +206,16 @@ fn exported_symbols_provider_local( })); } + if let Some(Sanitizer::Memory) = tcx.sess.opts.debugging_opts.sanitizer { + // Similar to profiling, preserve weak msan symbol during LTO. + const MSAN_WEAK_SYMBOLS: [&str; 2] = ["__msan_track_origins", "__msan_keep_going"]; + + symbols.extend(MSAN_WEAK_SYMBOLS.iter().map(|sym| { + let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(sym)); + (exported_symbol, SymbolExportLevel::C) + })); + } + if tcx.sess.crate_types.borrow().contains(&config::CrateType::Dylib) { let symbol_name = metadata_symbol_name(tcx); let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name)); diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index efd560071202c..1f43a4027c5ff 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -37,6 +37,7 @@ use rustc::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyLayout, VariantIdx}; use rustc::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA}; use rustc::ty::query::Providers; use rustc::ty::{self, Instance, Ty, TyCtxt}; +use rustc_attr as attr; use rustc_codegen_utils::{check_for_rustc_errors_attr, symbol_names_test}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::profiling::print_time_passes_entry; @@ -46,7 +47,6 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_index::vec::Idx; use rustc_session::cgu_reuse_tracker::CguReuse; use rustc_span::Span; -use syntax::attr; use std::cmp; use std::ops::{Deref, DerefMut}; diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index b856e5da5a093..7a5966269b301 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -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" } diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 6ef6dcf87eddb..345b03e6db243 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -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()) }) } diff --git a/src/librustc_expand/Cargo.toml b/src/librustc_expand/Cargo.toml index d04dd079be75d..cb7919d630ad4 100644 --- a/src/librustc_expand/Cargo.toml +++ b/src/librustc_expand/Cargo.toml @@ -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" } diff --git a/src/librustc_expand/base.rs b/src/librustc_expand/base.rs index 52ba14dbc3df0..a69efc47f67ee 100644 --- a/src/librustc_expand/base.rs +++ b/src/librustc_expand/base.rs @@ -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)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { match self { Annotatable::Item(item) => item.visit_attrs(f), Annotatable::TraitItem(trait_item) => trait_item.visit_attrs(f), diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs index 3254d0c913da3..5321092a4f7dc 100644 --- a/src/librustc_expand/expand.rs +++ b/src/librustc_expand/expand.rs @@ -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; @@ -1664,7 +1664,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), diff --git a/src/librustc_expand/mbe/macro_parser.rs b/src/librustc_expand/mbe/macro_parser.rs index 246f66084b813..0dfde53144866 100644 --- a/src/librustc_expand/mbe/macro_parser.rs +++ b/src/librustc_expand/mbe/macro_parser.rs @@ -76,12 +76,12 @@ 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::sess::ParseSess; use syntax::token::{self, DocComment, Nonterminal, Token}; use syntax::tokenstream::TokenStream; diff --git a/src/librustc_expand/mbe/macro_rules.rs b/src/librustc_expand/mbe/macro_rules.rs index d72317af9eb67..29d41543fbf8c 100644 --- a/src/librustc_expand/mbe/macro_rules.rs +++ b/src/librustc_expand/mbe/macro_rules.rs @@ -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}; diff --git a/src/librustc_expand/mbe/quoted.rs b/src/librustc_expand/mbe/quoted.rs index 4a33c51d57396..9ae8ead1a724d 100644 --- a/src/librustc_expand/mbe/quoted.rs +++ b/src/librustc_expand/mbe/quoted.rs @@ -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; diff --git a/src/librustc_expand/mut_visit/tests.rs b/src/librustc_expand/mut_visit/tests.rs index 003ce0fcb1fd4..49b9a1b1025ab 100644 --- a/src/librustc_expand/mut_visit/tests.rs +++ b/src/librustc_expand/mut_visit/tests.rs @@ -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. diff --git a/src/librustc_expand/parse/lexer/tests.rs b/src/librustc_expand/parse/lexer/tests.rs index 2ef81d80a1412..c486839dad506 100644 --- a/src/librustc_expand/parse/lexer/tests.rs +++ b/src/librustc_expand/parse/lexer/tests.rs @@ -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; diff --git a/src/librustc_expand/parse/tests.rs b/src/librustc_expand/parse/tests.rs index b79e2894126dd..3641f03cb30c5 100644 --- a/src/librustc_expand/parse/tests.rs +++ b/src/librustc_expand/parse/tests.rs @@ -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; diff --git a/src/librustc_expand/proc_macro_server.rs b/src/librustc_expand/proc_macro_server.rs index d441613ac58f4..a7397e576b18c 100644 --- a/src/librustc_expand/proc_macro_server.rs +++ b/src/librustc_expand/proc_macro_server.rs @@ -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; diff --git a/src/librustc_expand/tests.rs b/src/librustc_expand/tests.rs index 82ab74ac15004..4ed60465f24f2 100644 --- a/src/librustc_expand/tests.rs +++ b/src/librustc_expand/tests.rs @@ -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; diff --git a/src/librustc_hir/Cargo.toml b/src/librustc_hir/Cargo.toml index f2e420dbae640..3ae943a4ce08b 100644 --- a/src/librustc_hir/Cargo.toml +++ b/src/librustc_hir/Cargo.toml @@ -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"] } diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index b62a7e413e303..0db75454aee38 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -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, diff --git a/src/librustc_hir/print.rs b/src/librustc_hir/print.rs index b9598c9376146..b0d2f96c71a03 100644 --- a/src/librustc_hir/print.rs +++ b/src/librustc_hir/print.rs @@ -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 } } } diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml index 1fe5248dbf4ce..de7a9f4f5af1c 100644 --- a/src/librustc_interface/Cargo.toml +++ b/src/librustc_interface/Cargo.toml @@ -14,6 +14,7 @@ log = "0.4" rayon = { version = "0.3.0", package = "rustc-rayon" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } syntax = { path = "../libsyntax" } +rustc_attr = { path = "../librustc_attr" } rustc_builtin_macros = { path = "../librustc_builtin_macros" } rustc_expand = { path = "../librustc_expand" } rustc_parse = { path = "../librustc_parse" } diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index 9cd9eb66cf6c1..2a667541ad3e7 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -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 = result::Result; @@ -106,7 +106,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec) -> FxHashSet<(String, Option(); + .collect::(); cfg.into_iter().map(|(a, b)| (a.to_string(), b.map(|b| b.to_string()))).collect() }) } diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index d62c7539d5f21..c22c00e9154e7 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -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 } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 21f9fa4816591..8d1afabad012e 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -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,16 +548,16 @@ 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 { - out_directory: dirpath, - out_filestem: stem, - single_output_file: None, - extra: sess.opts.cg.extra_filename.clone(), - outputs: sess.opts.output_types.clone(), - } + OutputFilenames::new( + dirpath, + stem, + None, + sess.opts.cg.extra_filename.clone(), + sess.opts.output_types.clone(), + ) } Some(ref out_file) => { @@ -578,18 +579,13 @@ pub fn build_output_filenames( sess.warn("ignoring --out-dir flag due to -o flag"); } - OutputFilenames { - out_directory: out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(), - out_filestem: out_file - .file_stem() - .unwrap_or_default() - .to_str() - .unwrap() - .to_string(), - single_output_file: ofile, - extra: sess.opts.cg.extra_filename.clone(), - outputs: sess.opts.output_types.clone(), - } + OutputFilenames::new( + out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(), + out_file.file_stem().unwrap_or_default().to_str().unwrap().to_string(), + ofile, + sess.opts.cg.extra_filename.clone(), + sess.opts.output_types.clone(), + ) } } } diff --git a/src/librustc_lint/Cargo.toml b/src/librustc_lint/Cargo.toml index 7e23e70577975..27df0f904e48a 100644 --- a/src/librustc_lint/Cargo.toml +++ b/src/librustc_lint/Cargo.toml @@ -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" } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index c8d3d5f9c83d8..345665de63c3c 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -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; diff --git a/src/librustc_lint/levels.rs b/src/librustc_lint/levels.rs index d5bbdc53160f6..4f30d2b222684 100644 --- a/src/librustc_lint/levels.rs +++ b/src/librustc_lint/levels.rs @@ -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; diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index 394da4a5bb0c1..6fdbfea7f03b3 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -1,5 +1,6 @@ use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc::ty; +use rustc_attr as attr; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -9,7 +10,6 @@ use rustc_span::symbol::sym; use rustc_span::{symbol::Ident, BytePos, Span}; use rustc_target::spec::abi::Abi; use syntax::ast; -use syntax::attr; #[derive(PartialEq)] pub enum MethodLateContext { diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 674a82b61961c..bdad360e71747 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -5,6 +5,7 @@ use rustc::mir::interpret::{sign_extend, truncate}; use rustc::ty::layout::{self, IntegerExt, LayoutOf, SizeSkeleton, VariantIdx}; use rustc::ty::subst::SubstsRef; use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; +use rustc_attr as attr; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir as hir; @@ -15,7 +16,7 @@ use rustc_span::source_map; use rustc_span::symbol::sym; use rustc_span::Span; use rustc_target::spec::abi::Abi; -use syntax::{ast, attr}; +use syntax::ast; use log::debug; use std::cmp; diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 15158c09af074..369f75b64a7b9 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -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; diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index 6da584733aea0..a4fdcee5e1297 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -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" } diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index bbf6973be51a7..2fa9cb099dd51 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -2,6 +2,7 @@ use rustc::middle::cstore::{self, NativeLibrary}; use rustc::session::parse::feature_err; use rustc::session::Session; use rustc::ty::TyCtxt; +use rustc_attr as attr; use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; use rustc_hir as hir; @@ -9,7 +10,6 @@ use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_span::source_map::Span; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_target::spec::abi::Abi; -use syntax::attr; crate fn collect(tcx: TyCtxt<'_>) -> Vec { let mut collector = Collector { tcx, libs: Vec::new() }; diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index 6280121f65566..58cf142ab3a36 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -34,6 +34,7 @@ use std::u32; use log::debug; use proc_macro::bridge::client::ProcMacro; +use rustc_attr as attr; use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, ProcMacroDerive}; use rustc_serialize::{opaque, Decodable, Decoder, SpecializedDecoder}; @@ -41,7 +42,6 @@ use rustc_span::source_map::{self, respan, Spanned}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{self, hygiene::MacroKind, BytePos, Pos, Span, DUMMY_SP}; use syntax::ast::{self, Ident}; -use syntax::attr; pub use cstore_impl::{provide, provide_extern}; diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index 9d2bea28c8c2e..54fbdb14010c9 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -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()), diff --git a/src/librustc_metadata/rmeta/mod.rs b/src/librustc_metadata/rmeta/mod.rs index 426ea62b8cd4c..77ec3eb4555e3 100644 --- a/src/librustc_metadata/rmeta/mod.rs +++ b/src/librustc_metadata/rmeta/mod.rs @@ -10,6 +10,7 @@ use rustc::mir; use rustc::session::config::SymbolManglingVersion; use rustc::session::CrateDisambiguator; use rustc::ty::{self, ReprOptions, Ty}; +use rustc_attr as attr; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::MetadataRef; use rustc_hir as hir; @@ -21,7 +22,7 @@ use rustc_span::edition::Edition; use rustc_span::symbol::Symbol; use rustc_span::{self, Span}; use rustc_target::spec::{PanicStrategy, TargetTriple}; -use syntax::{ast, attr}; +use syntax::ast; use std::marker::PhantomData; use std::num::NonZeroUsize; diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index 00881e3ea6f19..6b2e2bb919c13 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -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" } diff --git a/src/librustc_mir/const_eval/fn_queries.rs b/src/librustc_mir/const_eval/fn_queries.rs index 2443e1e91d378..65b1ea3743c26 100644 --- a/src/librustc_mir/const_eval/fn_queries.rs +++ b/src/librustc_mir/const_eval/fn_queries.rs @@ -1,11 +1,11 @@ use rustc::hir::map::blocks::FnLikeNode; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; +use rustc_attr as attr; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_span::symbol::Symbol; use rustc_target::spec::abi::Abi; -use syntax::attr; /// Whether the `def_id` counts as const fn in your current crate, considering all active /// feature gates diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index e29730f267c2c..7cd7fc309b6b9 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -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}; diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 2dd00fe2fee19..3d4be3b6aca6b 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -16,8 +16,8 @@ use crate::transform::{MirPass, MirSource}; use std::collections::VecDeque; use std::iter; +use rustc_attr as attr; use rustc_target::spec::abi::Abi; -use syntax::attr; const DEFAULT_THRESHOLD: usize = 50; const HINT_THRESHOLD: usize = 100; diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs index b047e534e4f1c..fca600b426f5e 100644 --- a/src/librustc_mir/transform/qualify_min_const_fn.rs +++ b/src/librustc_mir/transform/qualify_min_const_fn.rs @@ -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>)>; diff --git a/src/librustc_mir_build/Cargo.toml b/src/librustc_mir_build/Cargo.toml index a22c4d18d516a..9ff3ed1a93588 100644 --- a/src/librustc_mir_build/Cargo.toml +++ b/src/librustc_mir_build/Cargo.toml @@ -15,6 +15,7 @@ itertools = "0.8" log = "0.4" rustc = { path = "../librustc" } rustc_apfloat = { path = "../librustc_apfloat" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_index = { path = "../librustc_index" } rustc_errors = { path = "../librustc_errors" } diff --git a/src/librustc_mir_build/build/matches/simplify.rs b/src/librustc_mir_build/build/matches/simplify.rs index a5f691add65c1..77dc7d5eb7cff 100644 --- a/src/librustc_mir_build/build/matches/simplify.rs +++ b/src/librustc_mir_build/build/matches/simplify.rs @@ -18,8 +18,8 @@ use crate::hair::{self, *}; use rustc::mir::interpret::truncate; use rustc::ty; use rustc::ty::layout::{Integer, IntegerExt, Size}; +use rustc_attr::{SignedInt, UnsignedInt}; use rustc_hir::RangeEnd; -use syntax::attr::{SignedInt, UnsignedInt}; use std::mem; diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index 44ff493b5b4f0..de09d6a0910a6 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -7,6 +7,7 @@ use rustc::middle::region; use rustc::mir::*; use rustc::ty::subst::Subst; use rustc::ty::{self, Ty, TyCtxt}; +use rustc_attr::{self as attr, UnwindAttr}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::{GeneratorKind, HirIdMap, Node}; @@ -16,7 +17,6 @@ use rustc_span::Span; use rustc_target::spec::abi::Abi; use rustc_target::spec::PanicStrategy; use std::u32; -use syntax::attr::{self, UnwindAttr}; use super::lints; diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs index 20183fd55c871..a192a1f693ee8 100644 --- a/src/librustc_mir_build/hair/pattern/_match.rs +++ b/src/librustc_mir_build/hair/pattern/_match.rs @@ -245,8 +245,8 @@ use rustc::mir::interpret::{truncate, AllocId, ConstValue, Pointer, Scalar}; use rustc::mir::Field; use rustc::util::common::ErrorReported; +use rustc_attr::{SignedInt, UnsignedInt}; use rustc_span::{Span, DUMMY_SP}; -use syntax::attr::{SignedInt, UnsignedInt}; use arena::TypedArena; diff --git a/src/librustc_mir_build/hair/pattern/mod.rs b/src/librustc_mir_build/hair/pattern/mod.rs index 2657050583071..bd8a9877719e4 100644 --- a/src/librustc_mir_build/hair/pattern/mod.rs +++ b/src/librustc_mir_build/hair/pattern/mod.rs @@ -1036,7 +1036,7 @@ crate fn compare_const_vals<'tcx>( } ty::Int(ity) => { use rustc::ty::layout::{Integer, IntegerExt}; - use syntax::attr::SignedInt; + use rustc_attr::SignedInt; let size = Integer::from_attr(&tcx, SignedInt(ity)).size(); let a = sign_extend(a, size); let b = sign_extend(b, size); diff --git a/src/librustc_parse/Cargo.toml b/src/librustc_parse/Cargo.toml index 8071bc6312b36..176bb58ad27e6 100644 --- a/src/librustc_parse/Cargo.toml +++ b/src/librustc_parse/Cargo.toml @@ -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" } diff --git a/src/librustc_parse/config.rs b/src/librustc_parse/config.rs index bf696faf2f3f4..5eed567333802 100644 --- a/src/librustc_parse/config.rs +++ b/src/librustc_parse/config.rs @@ -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; diff --git a/src/librustc_parse/lexer/mod.rs b/src/librustc_parse/lexer/mod.rs index 02e4808679f00..af56e9d344d2e 100644 --- a/src/librustc_parse/lexer/mod.rs +++ b/src/librustc_parse/lexer/mod.rs @@ -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; diff --git a/src/librustc_parse/lexer/tokentrees.rs b/src/librustc_parse/lexer/tokentrees.rs index a28bff3babfbf..c28b59a790801 100644 --- a/src/librustc_parse/lexer/tokentrees.rs +++ b/src/librustc_parse/lexer/tokentrees.rs @@ -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, diff --git a/src/librustc_parse/lib.rs b/src/librustc_parse/lib.rs index 08f4f210152dd..bf0f8ff0064d5 100644 --- a/src/librustc_parse/lib.rs +++ b/src/librustc_parse/lib.rs @@ -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; diff --git a/src/librustc_parse/parser/attr.rs b/src/librustc_parse/parser/attr.rs index 3d40b91a7bdc8..00f884bfbe27c 100644 --- a/src/librustc_parse/parser/attr.rs +++ b/src/librustc_parse/parser/attr.rs @@ -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; diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index 80bc5c158a64f..e2227f669738c 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -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; diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index 098c8355ab944..0d12f8cf6c039 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -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; diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 31db7fc5f759d..5191f921bc2b6 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -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}; diff --git a/src/librustc_parse/parser/mod.rs b/src/librustc_parse/parser/mod.rs index 4a9016394d258..1e28372c384f5 100644 --- a/src/librustc_parse/parser/mod.rs +++ b/src/librustc_parse/parser/mod.rs @@ -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}; diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index edb9044df9206..e07b0733739d1 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -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; diff --git a/src/librustc_passes/Cargo.toml b/src/librustc_passes/Cargo.toml index 338808f6d4a0f..981ef7f8796d3 100644 --- a/src/librustc_passes/Cargo.toml +++ b/src/librustc_passes/Cargo.toml @@ -11,6 +11,7 @@ path = "lib.rs" [dependencies] log = "0.4" rustc = { path = "../librustc" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_feature = { path = "../librustc_feature" } diff --git a/src/librustc_passes/stability.rs b/src/librustc_passes/stability.rs index 320b433190e5e..ff9e7d71c55df 100644 --- a/src/librustc_passes/stability.rs +++ b/src/librustc_passes/stability.rs @@ -10,6 +10,7 @@ use rustc::session::Session; use rustc::traits::misc::can_type_implement_copy; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; +use rustc_attr::{self as attr, Stability}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::struct_span_err; use rustc_hir as hir; @@ -20,7 +21,6 @@ use rustc_hir::{Generics, HirId, Item, StructField, Variant}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use syntax::ast::Attribute; -use syntax::attr::{self, Stability}; use std::cmp::Ordering; use std::mem::replace; diff --git a/src/librustc_privacy/Cargo.toml b/src/librustc_privacy/Cargo.toml index 4f341b545156c..2f7aaf9e5cfe1 100644 --- a/src/librustc_privacy/Cargo.toml +++ b/src/librustc_privacy/Cargo.toml @@ -10,6 +10,7 @@ path = "lib.rs" [dependencies] rustc = { path = "../librustc" } +rustc_attr = { path = "../librustc_attr" } rustc_errors = { path = "../librustc_errors" } rustc_hir = { path = "../librustc_hir" } rustc_typeck = { path = "../librustc_typeck" } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 60bf271d2d2a8..74bb72d6fad7f 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -11,6 +11,7 @@ use rustc::ty::fold::TypeVisitor; use rustc::ty::query::Providers; use rustc::ty::subst::InternalSubsts; use rustc::ty::{self, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeFoldable}; +use rustc_attr as attr; use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; use rustc_hir as hir; @@ -22,7 +23,6 @@ use rustc_span::hygiene::Transparency; use rustc_span::symbol::{kw, sym}; use rustc_span::Span; use syntax::ast::Ident; -use syntax::attr; use std::marker::PhantomData; use std::{cmp, fmt, mem}; diff --git a/src/librustc_resolve/Cargo.toml b/src/librustc_resolve/Cargo.toml index c4cc6b09c736e..f8c96ecaf9373 100644 --- a/src/librustc_resolve/Cargo.toml +++ b/src/librustc_resolve/Cargo.toml @@ -17,6 +17,8 @@ syntax = { path = "../libsyntax" } arena = { path = "../libarena" } rustc = { path = "../librustc" } rustc_ast_lowering = { path = "../librustc_ast_lowering" } +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_expand = { path = "../librustc_expand" } diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 7ff076268ab82..c77b588d7fbc3 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -20,6 +20,7 @@ use rustc::bug; use rustc::hir::exports::Export; use rustc::middle::cstore::CrateStore; use rustc::ty; +use rustc_attr as attr; use rustc_data_structures::sync::Lrc; use rustc_errors::{struct_span_err, Applicability}; use rustc_expand::base::SyntaxExtension; @@ -34,7 +35,6 @@ use rustc_span::{Span, DUMMY_SP}; use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId}; use syntax::ast::{AssocItem, AssocItemKind, MetaItemKind, StmtKind}; use syntax::ast::{Ident, Name}; -use syntax::attr; use syntax::token::{self, Token}; use syntax::visit::{self, Visitor}; diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 4a6df92d82260..e8e3b68579488 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -30,9 +30,9 @@ use rustc::{lint, ty}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::pluralize; use rustc_session::lint::BuiltinLintDiagnostics; -use rustc_session::node_id::NodeMap; use rustc_span::{MultiSpan, Span, DUMMY_SP}; use syntax::ast; +use syntax::node_id::NodeMap; use syntax::visit::{self, Visitor}; struct UnusedImport<'a> { diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 77dfe3d9f1d5a..389d512712deb 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -4,6 +4,7 @@ use log::debug; use rustc::bug; use rustc::session::Session; use rustc::ty::{self, DefIdTree}; +use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; use rustc_feature::BUILTIN_ATTRIBUTES; @@ -16,7 +17,6 @@ use rustc_span::source_map::SourceMap; use rustc_span::symbol::{kw, Symbol}; use rustc_span::{BytePos, MultiSpan, Span}; use syntax::ast::{self, Ident, Path}; -use syntax::print::pprust; use syntax::util::lev_distance::find_best_match_for_name; use crate::imports::{ImportDirective, ImportDirectiveSubclass, ImportResolver}; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 0e6f40fa8466a..089252ffe875f 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -25,6 +25,7 @@ use rustc::middle::cstore::{CrateStore, MetadataLoaderDyn}; use rustc::span_bug; use rustc::ty::query::Providers; use rustc::ty::{self, DefIdTree, ResolverOutputs}; +use rustc_ast_pretty::pprust; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_data_structures::ptr_key::PtrKey; use rustc_data_structures::sync::Lrc; @@ -37,7 +38,6 @@ use rustc_hir::PrimTy::{self, Bool, Char, Float, Int, Str, Uint}; use rustc_hir::{GlobMap, TraitMap}; use rustc_metadata::creader::{CStore, CrateLoader}; use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer}; -use rustc_session::node_id::{NodeMap, NodeSet}; use rustc_session::Session; use rustc_span::hygiene::{ExpnId, ExpnKind, MacroKind, SyntaxContext, Transparency}; use rustc_span::source_map::Spanned; @@ -47,7 +47,7 @@ use syntax::ast::{self, FloatTy, Ident, IntTy, Name, NodeId, UintTy}; use syntax::ast::{Crate, CRATE_NODE_ID}; use syntax::ast::{ItemKind, Path}; use syntax::attr; -use syntax::print::pprust; +use syntax::node_id::{NodeMap, NodeSet}; use syntax::unwrap_or; use syntax::visit::{self, Visitor}; diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 85b5d8ef1cb5d..11139a3dc94fc 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -10,6 +10,8 @@ use rustc::middle::stability; use rustc::session::parse::feature_err; use rustc::session::Session; use rustc::{lint, span_bug, ty}; +use rustc_ast_pretty::pprust; +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,8 +25,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; use rustc_span::hygiene::{AstPass, MacroKind}; diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index e7a7eefc509e1..2cbed75eaf597 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -11,6 +11,7 @@ path = "lib.rs" [dependencies] log = "0.4" rustc = { path = "../librustc" } +rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_codegen_utils = { path = "../librustc_codegen_utils" } rustc_hir = { path = "../librustc_hir" } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index d252fc542c325..a1d39bcdc3869 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -16,22 +16,21 @@ use rustc::session::config::Input; use rustc::span_bug; use rustc::ty::{self, DefIdTree, TyCtxt}; +use rustc_ast_pretty::pprust::{bounds_to_string, generic_params_to_string, ty_to_string}; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::{DefKind as HirDefKind, Res}; use rustc_hir::def_id::DefId; - -use std::env; -use std::path::Path; - use rustc_span::source_map::{respan, DUMMY_SP}; use rustc_span::*; use syntax::ast::{self, Attribute, NodeId, PatKind}; -use syntax::print::pprust::{bounds_to_string, generic_params_to_string, ty_to_string}; use syntax::ptr::P; use syntax::token; use syntax::visit::{self, Visitor}; use syntax::walk_list; +use std::env; +use std::path::Path; + use crate::dumper::{Access, Dumper}; use crate::sig; use crate::span_utils::SpanUtils; diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 537fe198a0c39..f74e6a64df536 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -13,11 +13,17 @@ use rustc::middle::privacy::AccessLevels; use rustc::session::config::{CrateType, Input, OutputType}; use rustc::ty::{self, DefIdTree, TyCtxt}; use rustc::{bug, span_bug}; +use rustc_ast_pretty::pprust::{self, param_to_string, ty_to_string}; use rustc_codegen_utils::link::{filename_for_metadata, out_filename}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind as HirDefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::Node; +use rustc_span::source_map::Spanned; +use rustc_span::*; +use syntax::ast::{self, Attribute, NodeId, PatKind, DUMMY_NODE_ID}; +use syntax::util::comments::strip_doc_comment_decoration; +use syntax::visit::{self, Visitor}; use std::cell::Cell; use std::default::Default; @@ -26,14 +32,6 @@ use std::fs::File; use std::io::BufWriter; use std::path::{Path, PathBuf}; -use rustc_span::source_map::Spanned; -use rustc_span::*; -use syntax::ast::{self, Attribute, NodeId, PatKind, DUMMY_NODE_ID}; -use syntax::print::pprust; -use syntax::print::pprust::{param_to_string, ty_to_string}; -use syntax::util::comments::strip_doc_comment_decoration; -use syntax::visit::{self, Visitor}; - use dump_visitor::DumpVisitor; use span_utils::SpanUtils; diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index a9d2bfabb1ba6..dbf29b6531d2a 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -29,9 +29,9 @@ use crate::{id_from_def_id, id_from_node_id, SaveContext}; use rls_data::{SigElement, Signature}; +use rustc_ast_pretty::pprust; use rustc_hir::def::{DefKind, Res}; use syntax::ast::{self, Extern, NodeId}; -use syntax::print::pprust; pub fn item_signature(item: &ast::Item, scx: &SaveContext<'_, '_>) -> Option { if !scx.config.signatures { diff --git a/src/librustc_session/Cargo.toml b/src/librustc_session/Cargo.toml index 47c23bc4dcf98..c74011e26aae8 100644 --- a/src/librustc_session/Cargo.toml +++ b/src/librustc_session/Cargo.toml @@ -19,3 +19,4 @@ rustc_span = { path = "../librustc_span" } rustc_index = { path = "../librustc_index" } rustc_fs_util = { path = "../librustc_fs_util" } num_cpus = "1.0" +syntax = { path = "../libsyntax" } diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs index b6b22e298ca62..c7fcd04c45a0a 100644 --- a/src/librustc_session/config.rs +++ b/src/librustc_session/config.rs @@ -447,9 +447,8 @@ impl Input { #[derive(Clone, Hash)] pub struct OutputFilenames { pub out_directory: PathBuf, - pub out_filestem: String, + filestem: String, pub single_output_file: Option, - pub extra: String, pub outputs: OutputTypes, } @@ -458,6 +457,21 @@ impl_stable_hash_via_hash!(OutputFilenames); pub const RUST_CGU_EXT: &str = "rcgu"; impl OutputFilenames { + pub fn new( + out_directory: PathBuf, + out_filestem: String, + single_output_file: Option, + extra: String, + outputs: OutputTypes, + ) -> Self { + OutputFilenames { + out_directory, + single_output_file, + outputs, + filestem: format!("{}{}", out_filestem, extra), + } + } + pub fn path(&self, flavor: OutputType) -> PathBuf { self.outputs .get(&flavor) @@ -477,8 +491,6 @@ impl OutputFilenames { /// Like temp_path, but also supports things where there is no corresponding /// OutputType, like noopt-bitcode or lto-bitcode. pub fn temp_path_ext(&self, ext: &str, codegen_unit_name: Option<&str>) -> PathBuf { - let base = self.out_directory.join(&self.filestem()); - let mut extension = String::new(); if let Some(codegen_unit_name) = codegen_unit_name { @@ -495,16 +507,13 @@ impl OutputFilenames { extension.push_str(ext); } - let path = base.with_extension(&extension[..]); - path + self.with_extension(&extension) } pub fn with_extension(&self, extension: &str) -> PathBuf { - self.out_directory.join(&self.filestem()).with_extension(extension) - } - - pub fn filestem(&self) -> String { - format!("{}{}", self.out_filestem, self.extra) + let mut path = self.out_directory.join(&self.filestem); + path.set_extension(extension); + path } } diff --git a/src/librustc_session/lib.rs b/src/librustc_session/lib.rs index 65d6635adad00..4101c32d547aa 100644 --- a/src/librustc_session/lib.rs +++ b/src/librustc_session/lib.rs @@ -10,7 +10,6 @@ pub mod cgu_reuse_tracker; pub mod utils; #[macro_use] pub mod lint; -pub mod node_id; pub mod parse; mod code_stats; diff --git a/src/librustc_session/lint.rs b/src/librustc_session/lint.rs index 2ba3932c7d97e..983dfb19919dd 100644 --- a/src/librustc_session/lint.rs +++ b/src/librustc_session/lint.rs @@ -1,8 +1,8 @@ pub use self::Level::*; -use crate::node_id::{NodeId, NodeMap}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; use rustc_span::edition::Edition; use rustc_span::{sym, symbol::Ident, MultiSpan, Span, Symbol}; +use syntax::node_id::{NodeId, NodeMap}; pub mod builtin; diff --git a/src/librustc_session/parse.rs b/src/librustc_session/parse.rs index 72c68fcb244c9..3264230026295 100644 --- a/src/librustc_session/parse.rs +++ b/src/librustc_session/parse.rs @@ -2,8 +2,6 @@ //! It also serves as an input to the parser itself. use crate::lint::{BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId}; -use crate::node_id::NodeId; - use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::{Lock, Lrc, Once}; use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler}; @@ -13,6 +11,7 @@ use rustc_span::edition::Edition; use rustc_span::hygiene::ExpnId; use rustc_span::source_map::{FilePathMapping, SourceMap}; use rustc_span::{MultiSpan, Span, Symbol}; +use syntax::node_id::NodeId; use std::path::PathBuf; use std::str; diff --git a/src/librustc_target/spec/armv7a_none_eabi.rs b/src/librustc_target/spec/armv7a_none_eabi.rs new file mode 100644 index 0000000000000..2fbef154f814c --- /dev/null +++ b/src/librustc_target/spec/armv7a_none_eabi.rs @@ -0,0 +1,48 @@ +// Generic ARMv7-A target for bare-metal code - floating point disabled +// +// This is basically the `armv7-unknown-linux-gnueabi` target with some changes +// (listed below) to bring it closer to the bare-metal `thumb` & `aarch64` +// targets: +// +// - `TargetOptions.features`: added `+strict-align`. rationale: unaligned +// memory access is disabled on boot on these cores +// - linker changed to LLD. rationale: C is not strictly needed to build +// bare-metal binaries (the `gcc` linker has the advantage that it knows where C +// libraries and crt*.o are but it's not much of an advantage here); LLD is also +// faster +// - `target_os` set to `none`. rationale: matches `thumb` targets +// - `target_{env,vendor}` set to an empty string. rationale: matches `thumb` +// targets +// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets +// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic +// linking. rationale: matches `thumb` targets + +use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions}; + +pub fn target() -> Result { + let opts = TargetOptions { + linker: Some("rust-lld".to_owned()), + features: "+v7,+thumb2,+soft-float,-neon,+strict-align".to_string(), + executables: true, + relocation_model: "static".to_string(), + disable_redzone: true, + max_atomic_width: Some(64), + panic_strategy: PanicStrategy::Abort, + abi_blacklist: super::arm_base::abi_blacklist(), + emit_debug_gdb_scripts: false, + ..Default::default() + }; + Ok(Target { + llvm_target: "armv7a-none-eabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_c_int_width: "32".to_string(), + target_os: "none".to_string(), + target_env: String::new(), + target_vendor: String::new(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), + options: opts, + }) +} diff --git a/src/librustc_target/spec/armv7a_none_eabihf.rs b/src/librustc_target/spec/armv7a_none_eabihf.rs new file mode 100644 index 0000000000000..f31e68c5bd12a --- /dev/null +++ b/src/librustc_target/spec/armv7a_none_eabihf.rs @@ -0,0 +1,36 @@ +// Generic ARMv7-A target for bare-metal code - floating point enabled (assumes +// FPU is present and emits FPU instructions) +// +// This is basically the `armv7-unknown-linux-gnueabihf` target with some +// changes (list in `armv7a_none_eabi.rs`) to bring it closer to the bare-metal +// `thumb` & `aarch64` targets. + +use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions}; + +pub fn target() -> Result { + let opts = TargetOptions { + linker: Some("rust-lld".to_owned()), + features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".to_string(), + executables: true, + relocation_model: "static".to_string(), + disable_redzone: true, + max_atomic_width: Some(64), + panic_strategy: PanicStrategy::Abort, + abi_blacklist: super::arm_base::abi_blacklist(), + emit_debug_gdb_scripts: false, + ..Default::default() + }; + Ok(Target { + llvm_target: "armv7a-none-eabihf".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_c_int_width: "32".to_string(), + target_os: "none".to_string(), + target_env: String::new(), + target_vendor: String::new(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), + options: opts, + }) +} diff --git a/src/librustc_target/spec/i686_unknown_freebsd.rs b/src/librustc_target/spec/i686_unknown_freebsd.rs index 88c944a6cb7eb..60f2188514e1b 100644 --- a/src/librustc_target/spec/i686_unknown_freebsd.rs +++ b/src/librustc_target/spec/i686_unknown_freebsd.rs @@ -4,7 +4,9 @@ pub fn target() -> TargetResult { let mut base = super::freebsd_base::opts(); base.cpu = "pentium4".to_string(); base.max_atomic_width = Some(64); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string()); + let pre_link_args = base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap(); + pre_link_args.push("-m32".to_string()); + pre_link_args.push("-Wl,-znotext".to_string()); base.stack_probes = true; Ok(Target { diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 528ffdf93a01a..67f45d3d230ef 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -472,6 +472,9 @@ supported_targets! { ("thumbv8m.main-none-eabi", thumbv8m_main_none_eabi), ("thumbv8m.main-none-eabihf", thumbv8m_main_none_eabihf), + ("armv7a-none-eabi", armv7a_none_eabi), + ("armv7a-none-eabihf", armv7a_none_eabihf), + ("msp430-none-elf", msp430_none_elf), ("aarch64-unknown-cloudabi", aarch64_unknown_cloudabi), diff --git a/src/librustc_typeck/Cargo.toml b/src/librustc_typeck/Cargo.toml index 4b27d86dd02a7..748bfcc79460a 100644 --- a/src/librustc_typeck/Cargo.toml +++ b/src/librustc_typeck/Cargo.toml @@ -14,6 +14,7 @@ doctest = false arena = { path = "../libarena" } log = "0.4" rustc = { path = "../librustc" } +rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_hir = { path = "../librustc_hir" } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 2dc198b6d9695..a833bbce3b88c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -115,6 +115,7 @@ use rustc::ty::{ self, AdtKind, CanonicalUserType, Const, GenericParamDefKind, RegionKind, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, UserType, WithConstness, }; +use rustc_attr as attr; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticId}; @@ -131,7 +132,6 @@ use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::{self, BytePos, MultiSpan, Span}; use rustc_target::spec::abi::Abi; use syntax::ast; -use syntax::attr; use syntax::util::parser::ExprPrecedence; use std::cell::{Cell, Ref, RefCell, RefMut}; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 5821977391b0a..d7f1848c305c5 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -33,6 +33,7 @@ use rustc::ty::util::Discr; use rustc::ty::util::IntTypeExt; use rustc::ty::{self, AdtKind, Const, DefIdTree, ToPolyTraitRef, Ty, TyCtxt, WithConstness}; use rustc::ty::{ReprOptions, ToPredicate}; +use rustc_attr::{list_contains_name, mark_used, InlineAttr, OptimizeAttr}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{struct_span_err, Applicability, StashKey}; @@ -46,7 +47,6 @@ use rustc_span::{Span, DUMMY_SP}; use rustc_target::spec::abi; use syntax::ast; use syntax::ast::{Ident, MetaItemKind}; -use syntax::attr::{list_contains_name, mark_used, InlineAttr, OptimizeAttr}; struct OnlySelfBounds(bool); diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 84e6ff648a38f..da3a277dc2ac6 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -8,9 +8,9 @@ use std::mem; use std::ops; use rustc_feature::Features; +use rustc_session::parse::ParseSess; use rustc_span::symbol::{sym, Symbol}; use syntax::ast::{LitKind, MetaItem, MetaItemKind, NestedMetaItem}; -use syntax::sess::ParseSess; use rustc_span::Span; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7a7d69c68a585..9d11ef1d95f10 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -16,6 +16,7 @@ use rustc::middle::stability; use rustc::ty::fold::TypeFolder; use rustc::ty::subst::InternalSubsts; use rustc::ty::{self, AdtKind, Lift, Ty, TyCtxt}; +use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; @@ -27,7 +28,6 @@ use rustc_span::symbol::{kw, sym}; use rustc_span::{self, Pos}; use rustc_typeck::hir_ty_to_ty; use syntax::ast::{self, Ident}; -use syntax::attr; use std::collections::hash_map::Entry; use std::default::Default; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 4c8b8112fa85a..cba16f9be543c 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -15,13 +15,13 @@ use rustc_lint; use rustc_resolve as resolve; use rustc_session::lint; +use rustc_attr as attr; use rustc_errors::emitter::{Emitter, EmitterWriter}; use rustc_errors::json::JsonEmitter; use rustc_span::source_map; use rustc_span::symbol::sym; use rustc_span::DUMMY_SP; use syntax::ast::CRATE_NODE_ID; -use syntax::attr; use rustc_data_structures::sync::{self, Lrc}; use std::cell::RefCell; diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 5bea1b5614159..9303ab634cd62 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -12,10 +12,10 @@ use std::io; use std::io::prelude::*; use rustc_parse::lexer; +use rustc_session::parse::ParseSess; use rustc_span::source_map::SourceMap; use rustc_span::symbol::{kw, sym}; use rustc_span::{FileName, Span}; -use syntax::sess::ParseSess; use syntax::token::{self, Token}; /// Highlights `src`, returning the HTML output. diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index ab38eec5f3ea9..8d99f7708ada6 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -44,6 +44,7 @@ use std::sync::Arc; use rustc::middle::privacy::AccessLevels; use rustc::middle::stability; +use rustc_ast_pretty::pprust; use rustc_data_structures::flock; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_feature::UnstableFeatures; @@ -57,7 +58,6 @@ use rustc_span::symbol::{sym, Symbol}; use serde::ser::SerializeSeq; use serde::{Serialize, Serializer}; use syntax::ast; -use syntax::print::pprust; use crate::clean::{self, AttributesExt, Deprecation, GetDefId, SelfTy}; use crate::config::RenderOptions; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 403c8d0160d8a..ed3f0f94e0ed8 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -21,6 +21,8 @@ extern crate env_logger; extern crate getopts; extern crate rustc; +extern crate rustc_ast_pretty; +extern crate rustc_attr; extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_errors; diff --git a/src/librustdoc/passes/check_code_block_syntax.rs b/src/librustdoc/passes/check_code_block_syntax.rs index 2903fd9dcd660..3b7c0db05a5e2 100644 --- a/src/librustdoc/passes/check_code_block_syntax.rs +++ b/src/librustdoc/passes/check_code_block_syntax.rs @@ -1,9 +1,9 @@ use rustc_data_structures::sync::{Lock, Lrc}; use rustc_errors::{emitter::Emitter, Applicability, Diagnostic, Handler}; use rustc_parse::lexer::StringReader as Lexer; +use rustc_session::parse::ParseSess; use rustc_span::source_map::{FilePathMapping, SourceMap}; use rustc_span::{FileName, InnerSpan}; -use syntax::sess::ParseSess; use syntax::token; use crate::clean; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index d89dc2adafeb3..936f63975a58e 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -141,7 +141,7 @@ pub fn run(options: Options) -> i32 { // Look for `#![doc(test(no_crate_inject))]`, used by crates in the std facade. fn scrape_test_config(krate: &::rustc_hir::Crate) -> TestOptions { - use syntax::print::pprust; + use rustc_ast_pretty::pprust; let mut opts = TestOptions { no_crate_inject: false, display_warnings: false, attrs: Vec::new() }; @@ -395,8 +395,8 @@ pub fn make_test( use rustc_errors::emitter::EmitterWriter; use rustc_errors::Handler; use rustc_parse::maybe_new_parser_from_source_str; + use rustc_session::parse::ParseSess; use rustc_span::source_map::FilePathMapping; - use syntax::sess::ParseSess; let filename = FileName::anon_source_code(s); let source = crates + &everything_else; diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml index 2e647d2a1e081..ff03ae3f425c4 100644 --- a/src/libsyntax/Cargo.toml +++ b/src/libsyntax/Cargo.toml @@ -13,12 +13,9 @@ doctest = false rustc_serialize = { path = "../libserialize", package = "serialize" } log = "0.4" scoped-tls = "1.0" -rustc_errors = { path = "../librustc_errors" } rustc_span = { path = "../librustc_span" } rustc_data_structures = { path = "../librustc_data_structures" } -rustc_feature = { path = "../librustc_feature" } rustc_index = { path = "../librustc_index" } rustc_lexer = { path = "../librustc_lexer" } rustc_macros = { path = "../librustc_macros" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } -rustc_session = { path = "../librustc_session" } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 5f38ac4cc0f42..7a46d69e30ab8 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -256,15 +256,7 @@ impl ParenthesizedArgs { } } -pub use rustc_session::node_id::NodeId; - -/// `NodeId` used to represent the root of the crate. -pub const CRATE_NODE_ID: NodeId = NodeId::from_u32_const(0); - -/// When parsing and doing expansions, we initially give all AST nodes this AST -/// node value. Then later, in the renumber pass, we renumber them to have -/// small, positive ids. -pub const DUMMY_NODE_ID: NodeId = NodeId::MAX; +pub use crate::node_id::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID}; /// A modifier on a bound, e.g., `?Sized` or `?const Trait`. /// @@ -432,8 +424,6 @@ pub struct WhereEqPredicate { pub rhs_ty: P, } -pub use rustc_session::parse::CrateConfig; - #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Crate { pub module: Mod, @@ -1427,7 +1417,7 @@ pub enum MacDelimiter { } impl MacDelimiter { - crate fn to_token(self) -> DelimToken { + pub fn to_token(self) -> DelimToken { match self { MacDelimiter::Parenthesis => DelimToken::Paren, MacDelimiter::Bracket => DelimToken::Bracket, @@ -1490,7 +1480,7 @@ pub struct StrLit { } impl StrLit { - crate fn as_lit(&self) -> Lit { + pub fn as_lit(&self) -> Lit { let token_kind = match self.style { StrStyle::Cooked => token::Str, StrStyle::Raw(n) => token::StrRaw(n), diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index ec05dab451af8..313f526923564 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -1,23 +1,18 @@ //! Functions dealing with attributes and meta items. -mod builtin; - -pub use crate::ast::Attribute; -pub use builtin::*; -pub use IntType::*; -pub use ReprAttr::*; -pub use StabilityLevel::*; - use crate::ast; -use crate::ast::{AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Ident, Name, Path, PathSegment}; +use crate::ast::{AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute}; use crate::ast::{Expr, GenericParam, Item, Lit, LitKind, Local, Stmt, StmtKind}; +use crate::ast::{Ident, Name, Path, PathSegment}; use crate::ast::{MacArgs, MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem}; use crate::mut_visit::visit_clobber; use crate::ptr::P; use crate::token::{self, Token}; use crate::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint}; -use crate::GLOBALS; +use rustc_data_structures::sync::Lock; +use rustc_index::bit_set::GrowableBitSet; +use rustc_span::edition::{Edition, DEFAULT_EDITION}; use rustc_span::source_map::{BytePos, Spanned}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; @@ -26,6 +21,35 @@ use log::debug; use std::iter; use std::ops::DerefMut; +pub struct Globals { + used_attrs: Lock>, + known_attrs: Lock>, + rustc_span_globals: rustc_span::Globals, +} + +impl Globals { + fn new(edition: Edition) -> Globals { + Globals { + // We have no idea how many attributes there will be, so just + // initiate the vectors with 0 bits. We'll grow them as necessary. + used_attrs: Lock::new(GrowableBitSet::new_empty()), + known_attrs: Lock::new(GrowableBitSet::new_empty()), + rustc_span_globals: rustc_span::Globals::new(edition), + } + } +} + +pub fn with_globals(edition: Edition, f: impl FnOnce() -> R) -> R { + let globals = Globals::new(edition); + GLOBALS.set(&globals, || rustc_span::GLOBALS.set(&globals.rustc_span_globals, f)) +} + +pub fn with_default_globals(f: impl FnOnce() -> R) -> R { + with_globals(DEFAULT_EDITION, f) +} + +scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals); + pub fn mark_used(attr: &Attribute) { debug!("marking {:?} as used", attr); GLOBALS.with(|globals| { @@ -382,30 +406,6 @@ pub fn find_by_name(attrs: &[Attribute], name: Symbol) -> Option<&Attribute> { attrs.iter().find(|attr| attr.check_name(name)) } -pub fn allow_internal_unstable<'a>( - attrs: &[Attribute], - span_diagnostic: &'a rustc_errors::Handler, -) -> Option + 'a> { - find_by_name(attrs, sym::allow_internal_unstable).and_then(|attr| { - attr.meta_item_list() - .or_else(|| { - span_diagnostic - .span_err(attr.span, "allow_internal_unstable expects list of feature names"); - None - }) - .map(|features| { - features.into_iter().filter_map(move |it| { - let name = it.ident().map(|ident| ident.name); - if name.is_none() { - span_diagnostic - .span_err(it.span(), "`allow_internal_unstable` expects feature names") - } - name - }) - }) - }) -} - pub fn filter_by_name(attrs: &[Attribute], name: Symbol) -> impl Iterator { attrs.iter().filter(move |attr| attr.check_name(name)) } @@ -626,15 +626,15 @@ impl NestedMetaItem { } pub trait HasAttrs: Sized { - fn attrs(&self) -> &[ast::Attribute]; - fn visit_attrs)>(&mut self, f: F); + fn attrs(&self) -> &[Attribute]; + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)); } impl HasAttrs for Spanned { - fn attrs(&self) -> &[ast::Attribute] { + fn attrs(&self) -> &[Attribute] { self.node.attrs() } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { self.node.visit_attrs(f); } } @@ -643,7 +643,7 @@ impl HasAttrs for Vec { fn attrs(&self) -> &[Attribute] { self } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { f(self) } } @@ -652,7 +652,7 @@ impl HasAttrs for AttrVec { fn attrs(&self) -> &[Attribute] { self } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { visit_clobber(self, |this| { let mut vec = this.into(); f(&mut vec); @@ -665,7 +665,7 @@ impl HasAttrs for P { fn attrs(&self) -> &[Attribute] { (**self).attrs() } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { (**self).visit_attrs(f); } } @@ -683,7 +683,7 @@ impl HasAttrs for StmtKind { } } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { match self { StmtKind::Local(local) => local.visit_attrs(f), StmtKind::Item(..) => {} @@ -702,21 +702,11 @@ impl HasAttrs for Stmt { self.kind.attrs() } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { self.kind.visit_attrs(f); } } -impl HasAttrs for GenericParam { - fn attrs(&self) -> &[ast::Attribute] { - &self.attrs - } - - fn visit_attrs)>(&mut self, f: F) { - self.attrs.visit_attrs(f); - } -} - macro_rules! derive_has_attrs { ($($ty:path),*) => { $( impl HasAttrs for $ty { @@ -724,7 +714,7 @@ macro_rules! derive_has_attrs { &self.attrs } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { self.attrs.visit_attrs(f); } } @@ -733,5 +723,5 @@ macro_rules! derive_has_attrs { derive_has_attrs! { Item, Expr, Local, ast::ForeignItem, ast::StructField, ast::AssocItem, ast::Arm, - ast::Field, ast::FieldPat, ast::Variant, ast::Param + ast::Field, ast::FieldPat, ast::Variant, ast::Param, GenericParam } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index b0c2aa3dbb28e..66c747f2c517a 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -17,11 +17,6 @@ #![feature(unicode_internals)] #![recursion_limit = "256"] -use ast::AttrId; -use rustc_data_structures::sync::Lock; -use rustc_index::bit_set::GrowableBitSet; -use rustc_span::edition::{Edition, DEFAULT_EDITION}; - #[macro_export] macro_rules! unwrap_or { ($opt:expr, $default:expr) => { @@ -32,62 +27,27 @@ macro_rules! unwrap_or { }; } -pub struct Globals { - used_attrs: Lock>, - known_attrs: Lock>, - rustc_span_globals: rustc_span::Globals, -} - -impl Globals { - fn new(edition: Edition) -> Globals { - Globals { - // We have no idea how many attributes there will be, so just - // initiate the vectors with 0 bits. We'll grow them as necessary. - used_attrs: Lock::new(GrowableBitSet::new_empty()), - known_attrs: Lock::new(GrowableBitSet::new_empty()), - rustc_span_globals: rustc_span::Globals::new(edition), - } - } -} - -pub fn with_globals(edition: Edition, f: impl FnOnce() -> R) -> R { - let globals = Globals::new(edition); - GLOBALS.set(&globals, || rustc_span::GLOBALS.set(&globals.rustc_span_globals, f)) -} - -pub fn with_default_globals(f: impl FnOnce() -> R) -> R { - with_globals(DEFAULT_EDITION, f) -} - -scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals); - pub mod util { pub mod classify; pub mod comments; pub mod lev_distance; pub mod literal; pub mod map_in_place; - pub mod node_count; pub mod parser; } pub mod ast; pub mod attr; +pub use attr::{with_default_globals, with_globals, GLOBALS}; pub mod entry; pub mod expand; pub mod mut_visit; +pub mod node_id; pub mod ptr; -pub use rustc_session::parse as sess; pub mod token; pub mod tokenstream; pub mod visit; -pub mod print { - mod helpers; - pub mod pp; - pub mod pprust; -} - use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; /// Requirements for a `StableHashingContext` to be used in this crate. diff --git a/src/librustc_session/node_id.rs b/src/libsyntax/node_id.rs similarity index 74% rename from src/librustc_session/node_id.rs rename to src/libsyntax/node_id.rs index 9fefe908e578e..58d2334a7b148 100644 --- a/src/librustc_session/node_id.rs +++ b/src/libsyntax/node_id.rs @@ -11,6 +11,14 @@ rustc_index::newtype_index! { rustc_data_structures::define_id_collections!(NodeMap, NodeSet, NodeId); +/// `NodeId` used to represent the root of the crate. +pub const CRATE_NODE_ID: NodeId = NodeId::from_u32_const(0); + +/// When parsing and doing expansions, we initially give all AST nodes this AST +/// node value. Then later, in the renumber pass, we renumber them to have +/// small, positive ids. +pub const DUMMY_NODE_ID: NodeId = NodeId::MAX; + impl NodeId { pub fn placeholder_from_expn_id(expn_id: ExpnId) -> Self { NodeId::from_u32(expn_id.as_u32()) diff --git a/src/libsyntax/util/comments.rs b/src/libsyntax/util/comments.rs index c385b498ced72..5a67531624d29 100644 --- a/src/libsyntax/util/comments.rs +++ b/src/libsyntax/util/comments.rs @@ -1,14 +1,11 @@ pub use CommentStyle::*; use crate::ast; -use crate::sess::ParseSess; - use rustc_span::source_map::SourceMap; use rustc_span::{BytePos, CharPos, FileName, Pos}; -use std::usize; - use log::debug; +use std::usize; #[cfg(test)] mod tests; @@ -191,8 +188,8 @@ fn split_block_comment_into_lines(text: &str, col: CharPos) -> Vec { // it appears this function is called only from pprust... that's // probably not a good thing. -crate fn gather_comments(sess: &ParseSess, path: FileName, src: String) -> Vec { - let cm = SourceMap::new(sess.source_map().path_mapping().clone()); +pub fn gather_comments(sm: &SourceMap, path: FileName, src: String) -> Vec { + let cm = SourceMap::new(sm.path_mapping().clone()); let source_file = cm.new_source_file(path, src); let text = (*source_file.src.as_ref().unwrap()).clone(); diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index a0ed89a9caef1..b98cc96b3c647 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -367,7 +367,7 @@ pub fn prec_let_scrutinee_needs_par() -> usize { /// /// Conversely, suppose that we have `(let _ = a) OP b` and `order` is that of `OP`. /// Can we print this as `let _ = a OP b`? -crate fn needs_par_as_let_scrutinee(order: i8) -> bool { +pub fn needs_par_as_let_scrutinee(order: i8) -> bool { order <= prec_let_scrutinee_needs_par() as i8 } diff --git a/src/test/codegen/sanitizer-memory-track-orgins.rs b/src/test/codegen/sanitizer-memory-track-orgins.rs index fd8be0bced796..1fd496b35dfcc 100644 --- a/src/test/codegen/sanitizer-memory-track-orgins.rs +++ b/src/test/codegen/sanitizer-memory-track-orgins.rs @@ -4,17 +4,21 @@ // needs-sanitizer-support // only-linux // only-x86_64 -// revisions:MSAN-0 MSAN-1 MSAN-2 +// revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO // //[MSAN-0] compile-flags: -Zsanitizer=memory //[MSAN-1] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1 //[MSAN-2] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins +//[MSAN-1-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1 -C lto=fat +//[MSAN-2-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins -C lto=fat #![crate_type="lib"] // MSAN-0-NOT: @__msan_track_origins // MSAN-1: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 1 // MSAN-2: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 2 +// MSAN-1-LTO: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 1 +// MSAN-2-LTO: @__msan_track_origins = weak_odr local_unnamed_addr constant i32 2 // // MSAN-0-LABEL: define void @copy( // MSAN-1-LABEL: define void @copy( diff --git a/src/test/codegen/sanitizer-recover.rs b/src/test/codegen/sanitizer-recover.rs index a292332667b54..9a583725b0bf0 100644 --- a/src/test/codegen/sanitizer-recover.rs +++ b/src/test/codegen/sanitizer-recover.rs @@ -4,31 +4,47 @@ // needs-sanitizer-support // only-linux // only-x86_64 -// revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER +// revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER MSAN-RECOVER-LTO +// no-prefer-dynamic // -//[ASAN] compile-flags: -Zsanitizer=address -//[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address -//[MSAN] compile-flags: -Zsanitizer=memory -//[MSAN-RECOVER] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory - -#![crate_type="lib"] +//[ASAN] compile-flags: -Zsanitizer=address +//[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address +//[MSAN] compile-flags: -Zsanitizer=memory +//[MSAN-RECOVER] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory +//[MSAN-RECOVER-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory -C lto=fat +// +// MSAN-NOT: @__msan_keep_going +// MSAN-RECOVER: @__msan_keep_going = weak_odr {{.*}} constant i32 1 +// MSAN-RECOVER-LTO: @__msan_keep_going = weak_odr {{.*}} constant i32 1 -// ASAN-LABEL: define i32 @penguin( +// ASAN-LABEL: define i32 @penguin( +// ASAN: call void @__asan_report_load4(i64 %0) +// ASAN: unreachable +// ASAN: } +// // ASAN-RECOVER-LABEL: define i32 @penguin( -// MSAN-LABEL: define i32 @penguin( +// ASAN-RECOVER: call void @__asan_report_load4_noabort( +// ASAN-RECOVER-NOT: unreachable +// ASAN: } +// +// MSAN-LABEL: define i32 @penguin( +// MSAN: call void @__msan_warning_noreturn() +// MSAN: unreachable +// MSAN: } +// // MSAN-RECOVER-LABEL: define i32 @penguin( +// MSAN-RECOVER: call void @__msan_warning() +// MSAN-RECOVER-NOT: unreachable +// MSAN-RECOVER: } +// +// MSAN-RECOVER-LTO-LABEL: define i32 @penguin( +// MSAN-RECOVER-LTO: call void @__msan_warning() +// MSAN-RECOVER-LTO-NOT: unreachable +// MSAN-RECOVER-LTO: } +// #[no_mangle] pub fn penguin(p: &mut i32) -> i32 { - // ASAN: call void @__asan_report_load4(i64 %0) - // ASAN: unreachable - // - // ASAN-RECOVER: call void @__asan_report_load4_noabort( - // ASAN-RECOVER-NOT: unreachable - // - // MSAN: call void @__msan_warning_noreturn() - // MSAN: unreachable - // - // MSAN-RECOVER: call void @__msan_warning() - // MSAN-RECOVER-NOT: unreachable *p } + +fn main() {} diff --git a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs index 725c350fe4e22..fbdad29d6494f 100644 --- a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs +++ b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs @@ -1,6 +1,7 @@ #![feature(box_syntax, plugin, plugin_registrar, rustc_private)] #![crate_type = "dylib"] +extern crate rustc_ast_pretty; extern crate rustc_driver; extern crate rustc_hir; #[macro_use] extern crate rustc_lint; @@ -8,13 +9,13 @@ extern crate rustc_hir; extern crate rustc_span; extern crate syntax; +use rustc_ast_pretty::pprust; use rustc_hir::intravisit; use rustc_hir as hir; use rustc_hir::Node; use rustc_lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; use rustc_driver::plugin::Registry; use rustc_span::source_map; -use syntax::print::pprust; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { diff --git a/src/test/ui-fulldeps/mod_dir_path_canonicalized.rs b/src/test/ui-fulldeps/mod_dir_path_canonicalized.rs index 2b4a9fb21e4c7..be4b49ada02c7 100644 --- a/src/test/ui-fulldeps/mod_dir_path_canonicalized.rs +++ b/src/test/ui-fulldeps/mod_dir_path_canonicalized.rs @@ -6,12 +6,13 @@ extern crate syntax; extern crate rustc_parse; +extern crate rustc_session; extern crate rustc_span; use rustc_parse::new_parser_from_file; +use rustc_session::parse::ParseSess; use rustc_span::source_map::FilePathMapping; use std::path::Path; -use syntax::sess::ParseSess; #[path = "mod_dir_simple/test.rs"] mod gravy; diff --git a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs index 04d1054e2877f..0f6a88b2691a8 100644 --- a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs @@ -19,19 +19,21 @@ #![feature(rustc_private)] +extern crate rustc_ast_pretty; extern crate rustc_data_structures; extern crate syntax; extern crate rustc_parse; +extern crate rustc_session; extern crate rustc_span; +use rustc_ast_pretty::pprust; use rustc_data_structures::thin_vec::ThinVec; use rustc_parse::new_parser_from_source_str; +use rustc_session::parse::ParseSess; use rustc_span::source_map::{Spanned, DUMMY_SP, FileName}; use rustc_span::source_map::FilePathMapping; use syntax::ast::*; -use syntax::sess::ParseSess; use syntax::mut_visit::{self, MutVisitor, visit_clobber}; -use syntax::print::pprust; use syntax::ptr::P; fn parse_expr(ps: &ParseSess, src: &str) -> Option> { diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs index f3be7b56db589..d996bf56fcc10 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs @@ -1,10 +1,9 @@ -// run-pass - #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash #[allow(dead_code)] -struct ArithArrayLen([u32; 0 + N]); // ok +struct ArithArrayLen([u32; 0 + N]); +//~^ ERROR constant expression depends on a generic parameter #[derive(PartialEq, Eq)] struct Config { @@ -12,7 +11,7 @@ struct Config { } struct B { - arr: [u8; CFG.arr_size], // ok + arr: [u8; CFG.arr_size], //~ ERROR constant expression depends on a generic parameter } const C: Config = Config { arr_size: 5 }; diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr b/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr index 274f97697029e..6ae70c493b1dd 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr @@ -1,8 +1,26 @@ warning: the feature `const_generics` is incomplete and may cause the compiler to crash - --> $DIR/array-size-in-generic-struct-param.rs:3:12 + --> $DIR/array-size-in-generic-struct-param.rs:1:12 | LL | #![feature(const_generics)] | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default +error: constant expression depends on a generic parameter + --> $DIR/array-size-in-generic-struct-param.rs:5:38 + | +LL | struct ArithArrayLen([u32; 0 + N]); + | ^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: constant expression depends on a generic parameter + --> $DIR/array-size-in-generic-struct-param.rs:14:5 + | +LL | arr: [u8; CFG.arr_size], + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/try-on-option-diagnostics.rs b/src/test/ui/try-on-option-diagnostics.rs index 65d5e29ec2f13..63d17414c313b 100644 --- a/src/test/ui/try-on-option-diagnostics.rs +++ b/src/test/ui/try-on-option-diagnostics.rs @@ -16,3 +16,32 @@ fn a_closure() -> u32 { }; a_closure() } + +fn a_method() -> u32 { + struct S; + + impl S { + fn a_method() { + let x: Option = None; + x?; //~ ERROR the `?` operator + } + } + + S::a_method(); + 22 +} + +fn a_trait_method() -> u32 { + struct S; + trait T { + fn a_trait_method() { + let x: Option = None; + x?; //~ ERROR the `?` operator + } + } + + impl T for S { } + + S::a_trait_method(); + 22 +} diff --git a/src/test/ui/try-on-option-diagnostics.stderr b/src/test/ui/try-on-option-diagnostics.stderr index ce3aca39fb8fb..c9dc3f1b87969 100644 --- a/src/test/ui/try-on-option-diagnostics.stderr +++ b/src/test/ui/try-on-option-diagnostics.stderr @@ -27,6 +27,32 @@ LL | | }; = help: the trait `std::ops::Try` is not implemented for `{integer}` = note: required by `std::ops::Try::from_error` -error: aborting due to 2 previous errors +error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `std::ops::Try`) + --> $DIR/try-on-option-diagnostics.rs:26:13 + | +LL | / fn a_method() { +LL | | let x: Option = None; +LL | | x?; + | | ^^ cannot use the `?` operator in a method that returns `()` +LL | | } + | |_________- this function should return `Result` or `Option` to accept `?` + | + = help: the trait `std::ops::Try` is not implemented for `()` + = note: required by `std::ops::Try::from_error` + +error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `std::ops::Try`) + --> $DIR/try-on-option-diagnostics.rs:39:13 + | +LL | / fn a_trait_method() { +LL | | let x: Option = None; +LL | | x?; + | | ^^ cannot use the `?` operator in a trait method that returns `()` +LL | | } + | |_________- this function should return `Result` or `Option` to accept `?` + | + = help: the trait `std::ops::Try` is not implemented for `()` + = note: required by `std::ops::Try::from_error` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index cff04e197e48a..98e9fe7a8b221 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -69,6 +69,7 @@ static TARGETS: &[&str] = &[ "thumbv7neon-linux-androideabi", "armv7-unknown-linux-gnueabi", "armv7-unknown-linux-gnueabihf", + "armv7a-none-eabi", "thumbv7neon-unknown-linux-gnueabihf", "armv7-unknown-linux-musleabi", "armv7-unknown-linux-musleabihf",