]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #65792 - Centril:split-syntax-2, r=petrochenkov
authorMazdak Farrokhzad <twingoow@gmail.com>
Mon, 28 Oct 2019 03:53:07 +0000 (04:53 +0100)
committerGitHub <noreply@github.com>
Mon, 28 Oct 2019 03:53:07 +0000 (04:53 +0100)
rustc, rustc_passes: reduce deps on rustc_expand

Part of #65324.

r? @petrochenkov

55 files changed:
Cargo.lock
src/librustc/Cargo.toml
src/librustc/hir/def.rs
src/librustc/hir/lowering.rs
src/librustc/hir/lowering/item.rs
src/librustc/hir/map/def_collector.rs
src/librustc/hir/map/definitions.rs
src/librustc/hir/map/mod.rs
src/librustc/ich/hcx.rs
src/librustc/ich/impls_syntax.rs
src/librustc/lint/mod.rs
src/librustc/session/mod.rs
src/librustc/ty/mod.rs
src/librustc_codegen_llvm/allocator.rs
src/librustc_codegen_llvm/lib.rs
src/librustc_codegen_ssa/Cargo.toml
src/librustc_codegen_ssa/back/symbol_export.rs
src/librustc_codegen_ssa/back/write.rs
src/librustc_codegen_ssa/traits/backend.rs
src/librustc_interface/passes.rs
src/librustc_metadata/creader.rs
src/librustc_metadata/decoder.rs
src/librustc_metadata/encoder.rs
src/librustc_passes/Cargo.toml
src/librustc_passes/ast_validation.rs
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/diagnostics.rs
src/librustc_resolve/late/diagnostics.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/macros.rs
src/librustc_resolve/resolve_imports.rs
src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs
src/librustdoc/doctree.rs
src/librustdoc/html/item_type.rs
src/librustdoc/html/render.rs
src/librustdoc/visit_ast.rs
src/libsyntax/attr/mod.rs
src/libsyntax/config.rs
src/libsyntax/expand/allocator.rs [new file with mode: 0644]
src/libsyntax/expand/mod.rs [new file with mode: 0644]
src/libsyntax/lib.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/parser/path.rs
src/libsyntax_expand/allocator.rs [deleted file]
src/libsyntax_expand/base.rs
src/libsyntax_expand/lib.rs
src/libsyntax_expand/proc_macro.rs
src/libsyntax_ext/deriving/clone.rs
src/libsyntax_ext/deriving/cmp/eq.rs
src/libsyntax_ext/deriving/cmp/partial_eq.rs
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/global_allocator.rs
src/libsyntax_ext/proc_macro_harness.rs
src/libsyntax_ext/standard_library_imports.rs

index 64f3a7ac619c2e37f55296d1c4789143cca51d20..4b264ef3f9fafab5380c75e73e47df034c5c7f6f 100644 (file)
@@ -3135,7 +3135,6 @@ dependencies = [
  "serialize",
  "smallvec",
  "syntax",
- "syntax_expand",
  "syntax_pos",
 ]
 
@@ -3451,7 +3450,6 @@ dependencies = [
  "rustc_target",
  "serialize",
  "syntax",
- "syntax_expand",
  "syntax_pos",
  "tempfile",
 ]
@@ -3707,7 +3705,6 @@ dependencies = [
  "rustc_index",
  "rustc_target",
  "syntax",
- "syntax_expand",
  "syntax_pos",
 ]
 
index 38631224fd359fd1651561207f19233851a5a11b..9d26ff6001767dcd1e97c6884271a3f397b7770b 100644 (file)
@@ -29,7 +29,6 @@ rustc_index = { path = "../librustc_index" }
 errors = { path = "../librustc_errors", package = "rustc_errors" }
 rustc_serialize = { path = "../libserialize", package = "serialize" }
 syntax = { path = "../libsyntax" }
-syntax_expand = { path = "../libsyntax_expand" }
 syntax_pos = { path = "../libsyntax_pos" }
 backtrace = "0.3.3"
 parking_lot = "0.9"
index a071a539e01df16e1ac32fd61a864dfbcabccb2a..d4d7af92fe359593f9516d83011d45ea74be5ce1 100644 (file)
@@ -6,8 +6,8 @@
 use crate::util::nodemap::DefIdMap;
 
 use syntax::ast;
-use syntax_expand::base::MacroKind;
 use syntax::ast::NodeId;
+use syntax_pos::hygiene::MacroKind;
 use syntax_pos::Span;
 use rustc_macros::HashStable;
 
index 002e6874466bbd12321c6256411c24d1499879c2..12ab44515c38d03b6e21102c743714b04b38908c 100644 (file)
@@ -64,7 +64,7 @@
 use syntax::ptr::P as AstP;
 use syntax::ast::*;
 use syntax::errors;
-use syntax_expand::base::SpecialDerives;
+use syntax::expand::SpecialDerives;
 use syntax::print::pprust;
 use syntax::parse::token::{self, Nonterminal, Token};
 use syntax::tokenstream::{TokenStream, TokenTree};
index 73d2ac5c134d3f1fa3465c2f391aa4cb5a12af2b..9da87090c79bb75bdfb17ca2b3449045ca78dfe4 100644 (file)
@@ -18,7 +18,7 @@
 use syntax::attr;
 use syntax::ast::*;
 use syntax::visit::{self, Visitor};
-use syntax_expand::base::SpecialDerives;
+use syntax::expand::SpecialDerives;
 use syntax::source_map::{respan, DesugaringKind, Spanned};
 use syntax::symbol::{kw, sym};
 use syntax_pos::Span;
index 7c8fdcc8b12e9795b9ab9bd642a073d88ec841c4..e9970e30bf9e5d716a33eff2839567be8dc61324 100644 (file)
@@ -2,10 +2,10 @@
 use crate::hir::def_id::DefIndex;
 
 use syntax::ast::*;
-use syntax_expand::hygiene::ExpnId;
 use syntax::visit;
 use syntax::symbol::{kw, sym};
 use syntax::parse::token::{self, Token};
+use syntax_pos::hygiene::ExpnId;
 use syntax_pos::Span;
 
 /// Creates `DefId`s for nodes in the AST.
index 58e638e93ba34463c8409300280ea6e565839300..4e163314f6b07de17d6279962cf7d0928a518020 100644 (file)
@@ -17,8 +17,8 @@
 use std::fmt::Write;
 use std::hash::Hash;
 use syntax::ast;
-use syntax_expand::hygiene::ExpnId;
-use syntax::symbol::{Symbol, sym};
+use syntax_pos::symbol::{Symbol, sym};
+use syntax_pos::hygiene::ExpnId;
 use syntax_pos::{Span, DUMMY_SP};
 
 /// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
index f839087ec027108677776a5b816cf1fdb1afe160..cd36944253dbbdc492e94f2ab36f4c9b0e52c994 100644 (file)
@@ -20,7 +20,7 @@
 use rustc_index::vec::IndexVec;
 use syntax::ast::{self, Name, NodeId};
 use syntax::source_map::Spanned;
-use syntax_expand::base::MacroKind;
+use syntax_pos::hygiene::MacroKind;
 use syntax_pos::{Span, DUMMY_SP};
 
 pub mod blocks;
index 14d0673ecc03fe51f3677cc1ecaa98973bb85332..957dab39414f04e4790e6edbd5cde05e424deb3e 100644 (file)
 
 use syntax::ast;
 use syntax::source_map::SourceMap;
-use syntax_expand::hygiene::SyntaxContext;
 use syntax::symbol::Symbol;
 use syntax::tokenstream::DelimSpan;
 use syntax_pos::{Span, DUMMY_SP};
-use syntax_pos::hygiene;
+use syntax_pos::hygiene::{self, SyntaxContext};
 
 use rustc_data_structures::stable_hasher::{
     HashStable, StableHasher, ToStableHashKey,
index 2510d7efb59e7eac876a753925dc54a4c8f355ba..51aa79078f2fc3ad89bb97b1d45494c884990b4f 100644 (file)
@@ -60,7 +60,7 @@ fn to_stable_hash_key(&self,
     Intel
 });
 
-impl_stable_hash_for!(enum ::syntax_expand::base::MacroKind {
+impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind {
     Bang,
     Attr,
     Derive,
index 3c35bdae66e9d5ab2f9721d53f50104be82459bc..4da146b1e5d57dedd77167ee25ab2fe7fba9eb7b 100644 (file)
@@ -39,8 +39,8 @@
 use syntax::source_map::{MultiSpan, ExpnKind, DesugaringKind};
 use syntax::early_buffered_lints::BufferedEarlyLintId;
 use syntax::edition::Edition;
-use syntax_expand::base::MacroKind;
 use syntax::symbol::{Symbol, sym};
+use syntax_pos::hygiene::MacroKind;
 use syntax_pos::Span;
 
 pub use crate::lint::context::{LateContext, EarlyContext, LintContext, LintStore,
index bd2460cfab116ed3b17de3c7c591ce2f78495aae..8bf4765111d36cae823d9477b95e50afa7a6fc6b 100644 (file)
@@ -24,7 +24,7 @@
 use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
 use syntax::ast::{self, NodeId};
 use syntax::edition::Edition;
-use syntax_expand::allocator::AllocatorKind;
+use syntax::expand::allocator::AllocatorKind;
 use syntax::feature_gate::{self, AttributeType};
 use syntax::json::JsonEmitter;
 use syntax::source_map;
index eb673fcefcc9a3fad4e53fed1863405af351c2b8..60028f2488a337dfe4048f76854e77eff7ed8481 100644 (file)
@@ -46,8 +46,8 @@
 use std::ops::Range;
 use syntax::ast::{self, Name, Ident, NodeId};
 use syntax::attr;
-use syntax_expand::hygiene::ExpnId;
-use syntax::symbol::{kw, sym, Symbol};
+use syntax_pos::symbol::{kw, sym, Symbol};
+use syntax_pos::hygiene::ExpnId;
 use syntax_pos::Span;
 
 use smallvec;
index 8c60c030eacdb3a1e864e4995ef925cfaccb8a86..11b6e0befa1b10fb28c35c3f1297a1d419ded267 100644 (file)
@@ -3,7 +3,7 @@
 use crate::attributes;
 use libc::c_uint;
 use rustc::ty::TyCtxt;
-use syntax_expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
+use syntax::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
 
 use crate::ModuleLlvm;
 use crate::llvm::{self, False, True};
index e09b600afd4e5a4955bc76e0ef6a78f5f2de877d..2ad6c28cd0838d2c24b58b9e5b5b19f5ebda4228 100644 (file)
@@ -39,7 +39,6 @@
 
 #[macro_use] extern crate log;
 extern crate syntax;
-extern crate syntax_expand;
 extern crate syntax_pos;
 extern crate rustc_errors as errors;
 
@@ -49,7 +48,7 @@
 use rustc_codegen_ssa::CompiledModule;
 use errors::{FatalError, Handler};
 use rustc::dep_graph::WorkProduct;
-use syntax_expand::allocator::AllocatorKind;
+use syntax::expand::allocator::AllocatorKind;
 pub use llvm_util::target_features;
 use std::any::Any;
 use std::sync::Arc;
index 6992f93d9994950e425ac467e5c28d3066bf938e..c7d09a423d5e3b7c2ec9aef13a13a4480c66c811 100644 (file)
@@ -21,7 +21,6 @@ tempfile = "3.1"
 
 rustc_serialize = { path = "../libserialize", package = "serialize" }
 syntax = { path = "../libsyntax" }
-syntax_expand = { path = "../libsyntax_expand" }
 syntax_pos = { path = "../libsyntax_pos" }
 rustc = { path = "../librustc" }
 rustc_apfloat = { path = "../librustc_apfloat" }
index d866a10f06935b55117f0a7b95469297add79afb..9443f225723788faaac36c3849ea27ab752d8027 100644 (file)
@@ -14,7 +14,7 @@
 use rustc::ty::subst::SubstsRef;
 use rustc::util::nodemap::{FxHashMap, DefIdMap};
 use rustc_index::vec::IndexVec;
-use syntax_expand::allocator::ALLOCATOR_METHODS;
+use syntax::expand::allocator::ALLOCATOR_METHODS;
 
 pub type ExportedSymbols = FxHashMap<
     CrateNum,
index 762b50f1659ccd7b00a536aa78ecbe482c227eda..b302b9ae7f0e4a4b9997cf10dcb6234c25e4e5b2 100644 (file)
@@ -27,7 +27,7 @@
 use rustc_errors::emitter::{Emitter};
 use rustc_target::spec::MergeFunctions;
 use syntax::attr;
-use syntax_expand::hygiene::ExpnId;
+use syntax_pos::hygiene::ExpnId;
 use syntax_pos::symbol::{Symbol, sym};
 use jobserver::{Client, Acquired};
 
index 1fff740d7403fee1bf7e026cbb683b87dd0ad0e8..8ab8243afdab7c43f88038d0abffd89fd53fc773 100644 (file)
@@ -9,7 +9,7 @@
 use rustc_codegen_utils::codegen_backend::CodegenBackend;
 use std::sync::Arc;
 use std::sync::mpsc;
-use syntax_expand::allocator::AllocatorKind;
+use syntax::expand::allocator::AllocatorKind;
 use syntax_pos::symbol::Symbol;
 
 pub trait BackendTypes {
index 58936172c5bcec0cd73a73b4d16528caf0046f5d..b8593bd91990e0efac2c283fe73946c6e34cd030 100644 (file)
@@ -502,7 +502,7 @@ pub fn lower_to_hir(
 
     // Discard hygiene data, which isn't required after lowering to HIR.
     if !sess.opts.debugging_opts.keep_hygiene_data {
-        syntax_expand::hygiene::clear_syntax_context_map();
+        syntax_pos::hygiene::clear_syntax_context_map();
     }
 
     Ok(hir_forest)
index f0a68058de8ca89e414d553f6669d509c1134bb5..234a5395047c6a321d2166a020ee45d759922e7d 100644 (file)
@@ -25,7 +25,7 @@
 
 use syntax::ast;
 use syntax::attr;
-use syntax_expand::allocator::{global_allocator_spans, AllocatorKind};
+use syntax::expand::allocator::{global_allocator_spans, AllocatorKind};
 use syntax::symbol::{Symbol, sym};
 use syntax::span_fatal;
 use syntax_pos::{Span, DUMMY_SP};
index 09ff7891a9debce40b602f16bf7db5a0bbdcf4e9..0e6ecbbf0176a8c0a69900df4e12e21ca89eafac 100644 (file)
 use syntax::attr;
 use syntax::ast::{self, Ident};
 use syntax::source_map::{self, respan, Spanned};
-use syntax::symbol::{Symbol, sym};
-use syntax_expand::base::{MacroKind, SyntaxExtensionKind, SyntaxExtension};
-use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP};
+use syntax_expand::base::{SyntaxExtensionKind, SyntaxExtension};
+use syntax_expand::proc_macro::{AttrProcMacro, ProcMacroDerive, BangProcMacro};
+use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, hygiene::MacroKind};
+use syntax_pos::symbol::{Symbol, sym};
 use log::debug;
 use proc_macro::bridge::client::ProcMacro;
-use syntax_expand::proc_macro::{AttrProcMacro, ProcMacroDerive, BangProcMacro};
 
 crate struct DecodeContext<'a, 'tcx> {
     opaque: opaque::Decoder<'a>,
index 08554c83ed5bf0e325e7727c1a5ad2c01eafb8d7..f6498f4eaa8919011a212465d0c3c971fb58acc2 100644 (file)
@@ -32,7 +32,7 @@
 use std::u32;
 use syntax::ast;
 use syntax::attr;
-use syntax_expand::proc_macro::is_proc_macro_attr;
+use syntax::expand::is_proc_macro_attr;
 use syntax::source_map::Spanned;
 use syntax::symbol::{kw, sym, Ident, Symbol};
 use syntax_pos::{self, FileName, SourceFile, Span};
index 118deb560d62f1dff29252f4782fa640b6399716..9d29a230314437f8e6b887d91c901551ebffdd78 100644 (file)
@@ -13,7 +13,6 @@ log = "0.4"
 rustc = { path = "../librustc" }
 rustc_data_structures = { path = "../librustc_data_structures" }
 syntax = { path = "../libsyntax" }
-syntax_expand = { path = "../libsyntax_expand" }
 syntax_pos = { path = "../libsyntax_pos" }
 errors = { path = "../librustc_errors", package = "rustc_errors" }
 rustc_target = { path = "../librustc_target" }
index 74de31263d3944104009f40cf886fc3b67de4ef1..994e9405fb6431c033d6bfb39c06ea84fc7f8f7f 100644 (file)
@@ -14,7 +14,7 @@
 use rustc_data_structures::fx::FxHashMap;
 use syntax::ast::*;
 use syntax::attr;
-use syntax_expand::proc_macro::is_proc_macro_attr;
+use syntax::expand::is_proc_macro_attr;
 use syntax::feature_gate::is_builtin_attr;
 use syntax::source_map::Spanned;
 use syntax::symbol::{kw, sym};
index c0fb8e33a819eb6ec0bc6313a20e9c4447edbe52..d0725c7b8028d1c79c2ab193c59113feb37cc372 100644 (file)
@@ -32,9 +32,6 @@
 
 use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId};
 use syntax::ast::{MetaItemKind, StmtKind, TraitItem, TraitItemKind};
-use syntax_expand::base::{MacroKind, SyntaxExtension};
-use syntax_expand::expand::AstFragment;
-use syntax_expand::hygiene::ExpnId;
 use syntax::feature_gate::is_builtin_attr;
 use syntax::parse::token::{self, Token};
 use syntax::print::pprust;
@@ -42,7 +39,9 @@
 use syntax::source_map::{respan, Spanned};
 use syntax::symbol::{kw, sym};
 use syntax::visit::{self, Visitor};
-
+use syntax_expand::base::SyntaxExtension;
+use syntax_expand::expand::AstFragment;
+use syntax_pos::hygiene::{MacroKind, ExpnId};
 use syntax_pos::{Span, DUMMY_SP};
 
 use log::debug;
index 7634093fbefbac29bbbb8f0336bc92a40ed95011..c0dfb7381acc255f3767a21778a9fec1bea398cb 100644 (file)
 use rustc::ty::{self, DefIdTree};
 use rustc::util::nodemap::FxHashSet;
 use syntax::ast::{self, Ident, Path};
-use syntax_expand::base::MacroKind;
 use syntax::feature_gate::BUILTIN_ATTRIBUTES;
 use syntax::source_map::SourceMap;
 use syntax::struct_span_err;
 use syntax::symbol::{Symbol, kw};
 use syntax::util::lev_distance::find_best_match_for_name;
+use syntax_pos::hygiene::MacroKind;
 use syntax_pos::{BytePos, Span, MultiSpan};
 
 use crate::resolve_imports::{ImportDirective, ImportDirectiveSubclass, ImportResolver};
index 07f44e0742e34b2745a616a00cf102d4d5a5c316..3e896e373fb01cbd8c91e3e14e31b8531818b887 100644 (file)
@@ -13,9 +13,9 @@
 use rustc::session::config::nightly_options;
 use rustc::util::nodemap::FxHashSet;
 use syntax::ast::{self, Expr, ExprKind, Ident, NodeId, Path, Ty, TyKind};
-use syntax_expand::base::MacroKind;
 use syntax::symbol::kw;
 use syntax::util::lev_distance::find_best_match_for_name;
+use syntax_pos::hygiene::MacroKind;
 use syntax_pos::Span;
 
 type Res = def::Res<ast::NodeId>;
index 92392806347244ce9e65f93f4b61b85494b04afd..cea205a8236650691d3ec4f208527dd5e5b05258 100644 (file)
 use rustc_metadata::creader::CrateLoader;
 use rustc_metadata::cstore::CStore;
 
-use syntax_expand::hygiene::{ExpnId, Transparency, SyntaxContext};
-use syntax_expand::base::{SyntaxExtension, MacroKind, SpecialDerives};
 use syntax::{struct_span_err, unwrap_or};
-use syntax::attr;
+use syntax::expand::SpecialDerives;
 use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy};
-use syntax::ast::{ItemKind, Path, CRATE_NODE_ID, Crate};
+use syntax::ast::{CRATE_NODE_ID, Crate};
+use syntax::ast::{ItemKind, Path};
+use syntax::attr;
 use syntax::print::pprust;
 use syntax::symbol::{kw, sym};
 use syntax::source_map::Spanned;
 use syntax::visit::{self, Visitor};
-
+use syntax_expand::base::SyntaxExtension;
+use syntax_pos::hygiene::{MacroKind, ExpnId, Transparency, SyntaxContext};
 use syntax_pos::{Span, DUMMY_SP};
 use errors::{Applicability, DiagnosticBuilder};
 
index 94fe0cc57403e7a376a5d66384839e1a484b529e..8b1b6db3ddc230342d43c38ef1a70ef6a64f4c98 100644 (file)
 use syntax::ast::{self, NodeId, Ident};
 use syntax::attr::StabilityLevel;
 use syntax::edition::Edition;
-use syntax_expand::base::{self, InvocationRes, Indeterminate, SpecialDerives};
-use syntax_expand::base::{MacroKind, SyntaxExtension};
-use syntax_expand::expand::{AstFragment, AstFragmentKind, Invocation, InvocationKind};
-use syntax_expand::hygiene::{self, ExpnId, ExpnData, ExpnKind};
-use syntax_expand::compile_declarative_macro;
+use syntax::expand::SpecialDerives;
 use syntax::feature_gate::{emit_feature_err, is_builtin_attr_name};
 use syntax::feature_gate::GateIssue;
 use syntax::print::pprust;
 use syntax::symbol::{Symbol, kw, sym};
+use syntax_expand::base::{self, InvocationRes, Indeterminate};
+use syntax_expand::base::SyntaxExtension;
+use syntax_expand::expand::{AstFragment, AstFragmentKind, Invocation, InvocationKind};
+use syntax_expand::compile_declarative_macro;
+use syntax_pos::hygiene::{self, ExpnId, ExpnData, ExpnKind};
 use syntax_pos::{Span, DUMMY_SP};
 
 use std::{mem, ptr};
 use rustc_data_structures::sync::Lrc;
-use syntax_pos::hygiene::AstPass;
+use syntax_pos::hygiene::{MacroKind, AstPass};
 
 type Res = def::Res<NodeId>;
 
index 31340ddd68372f18455ab587247f4eaea20d3d69..c95009858e4c0f91353cf3681043a841dbf26206 100644 (file)
 use rustc::{bug, span_bug};
 
 use syntax::ast::{Ident, Name, NodeId, CRATE_NODE_ID};
-use syntax_expand::hygiene::ExpnId;
 use syntax::symbol::kw;
 use syntax::util::lev_distance::find_best_match_for_name;
 use syntax::{struct_span_err, unwrap_or};
+use syntax_pos::hygiene::ExpnId;
 use syntax_pos::{MultiSpan, Span};
 
 use log::*;
index a6a8fec429e20ec80030a282350a18e6bf274738..b3b3750320a95c75df46cf91ed4b4278d174d512 100644 (file)
@@ -3,8 +3,8 @@
 use std::iter::once;
 
 use syntax::ast;
-use syntax_expand::base::MacroKind;
 use syntax::symbol::sym;
+use syntax_pos::hygiene::MacroKind;
 use syntax_pos::Span;
 
 use rustc::hir;
index a642491b28181145e59f4b4f01b68f3ba9fa9918..bdc0206223036d2a8b7a823dc391a33eeb28afec 100644 (file)
 use rustc::util::nodemap::{FxHashMap, FxHashSet};
 use syntax::ast::{self, Attribute, AttrStyle, AttrItem, Ident};
 use syntax::attr;
-use syntax_expand::base::MacroKind;
 use syntax::parse::lexer::comments;
 use syntax::source_map::DUMMY_SP;
-use syntax::symbol::{Symbol, kw, sym};
+use syntax_pos::symbol::{Symbol, kw, sym};
+use syntax_pos::hygiene::MacroKind;
 use syntax_pos::{self, Pos, FileName};
 
 use std::collections::hash_map::Entry;
index bbc00147ee14eff21943d41dd838c0268c7df1cd..002ca6fe983ba0c89c74df32356b505debdf82b2 100644 (file)
@@ -4,7 +4,7 @@
 
 use syntax::ast;
 use syntax::ast::Name;
-use syntax_expand::base::MacroKind;
+use syntax_pos::hygiene::MacroKind;
 use syntax_pos::{self, Span};
 
 use rustc::hir;
index e015739b03c40b358c10b0822bfd9d4106d9e161..f5e45924893eabbcc82c7ed1884b6d89ea827cc6 100644 (file)
@@ -1,7 +1,7 @@
 //! Item types.
 
 use std::fmt;
-use syntax_expand::base::MacroKind;
+use syntax_pos::hygiene::MacroKind;
 use crate::clean;
 
 /// Item type. Corresponds to `clean::ItemEnum` variants.
index 414c3137376a95f2d45c1dc7c12090aa9508a2f1..c4ee84d33f39b3ebf322ae28a86cdc0387769428 100644 (file)
@@ -49,7 +49,7 @@
 use syntax::print::pprust;
 use syntax::source_map::FileName;
 use syntax::symbol::{Symbol, sym};
-use syntax_expand::base::MacroKind;
+use syntax_pos::hygiene::MacroKind;
 use rustc::hir::def_id::DefId;
 use rustc::middle::privacy::AccessLevels;
 use rustc::middle::stability;
index 70c30687dabca6b45abb87f7751ba3bac87b215b..5a83569f02a5c344df6348ea7d7e271de69b3333 100644 (file)
@@ -8,9 +8,9 @@
 use rustc::util::nodemap::{FxHashSet, FxHashMap};
 use rustc::ty::TyCtxt;
 use syntax::ast;
-use syntax_expand::base::MacroKind;
 use syntax::source_map::Spanned;
 use syntax::symbol::sym;
+use syntax_pos::hygiene::MacroKind;
 use syntax_pos::{self, Span};
 
 use std::mem;
index 27de084ae98ca25fc688eddc3d42f261c18721c3..3e240a855e280105f09943d20fe31568ab870cbe 100644 (file)
@@ -15,7 +15,7 @@
 use crate::mut_visit::visit_clobber;
 use crate::source_map::{BytePos, Spanned};
 use crate::parse::lexer::comments::doc_comment_style;
-use crate::parse::parser::Parser;
+use crate::parse;
 use crate::parse::PResult;
 use crate::parse::token::{self, Token};
 use crate::ptr::P;
@@ -280,35 +280,10 @@ pub fn meta(&self) -> Option<MetaItem> {
         self.item.meta(self.span)
     }
 
-    crate fn parse<'a, T, F>(&self, sess: &'a ParseSess, mut f: F) -> PResult<'a, T>
-        where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>,
-    {
-        let mut parser = Parser::new(
-            sess,
-            self.tokens.clone(),
-            None,
-            false,
-            false,
-            Some("attribute"),
-        );
-        let result = f(&mut parser)?;
-        if parser.token != token::Eof {
-            parser.unexpected()?;
-        }
-        Ok(result)
-    }
-
-    pub fn parse_derive_paths<'a>(&self, sess: &'a ParseSess) -> PResult<'a, Vec<Path>> {
-        if self.tokens.is_empty() {
-            return Ok(Vec::new());
-        }
-        self.parse(sess, |p| p.parse_derive_paths())
-    }
-
     pub fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> {
         Ok(MetaItem {
             path: self.path.clone(),
-            kind: self.parse(sess, |parser| parser.parse_meta_item_kind())?,
+            kind: parse::parse_in_attr(sess, self, |p| p.parse_meta_item_kind())?,
             span: self.span,
         })
     }
index 54dc95291d67f5d07ae31ac7374c88add4a02f5a..6003fd1d2861a5cee84df5516bcf1c6e20e06db6 100644 (file)
@@ -10,6 +10,7 @@
 use crate::ast;
 use crate::edition::Edition;
 use crate::mut_visit::*;
+use crate::parse;
 use crate::ptr::P;
 use crate::sess::ParseSess;
 use crate::symbol::sym;
@@ -112,7 +113,8 @@ fn process_cfg_attr(&mut self, attr: ast::Attribute) -> Vec<ast::Attribute> {
             return vec![];
         }
 
-        let (cfg_predicate, expanded_attrs) = match attr.parse(self.sess, |p| p.parse_cfg_attr()) {
+        let res = parse::parse_in_attr(self.sess, &attr, |p| p.parse_cfg_attr());
+        let (cfg_predicate, expanded_attrs) = match res {
             Ok(result) => result,
             Err(mut e) => {
                 e.emit();
diff --git a/src/libsyntax/expand/allocator.rs b/src/libsyntax/expand/allocator.rs
new file mode 100644 (file)
index 0000000..20487b9
--- /dev/null
@@ -0,0 +1,75 @@
+use crate::{ast, attr, visit};
+use syntax_pos::symbol::{sym, Symbol};
+use syntax_pos::Span;
+
+#[derive(Clone, Copy)]
+pub enum AllocatorKind {
+    Global,
+    DefaultLib,
+    DefaultExe,
+}
+
+impl AllocatorKind {
+    pub fn fn_name(&self, base: &str) -> String {
+        match *self {
+            AllocatorKind::Global => format!("__rg_{}", base),
+            AllocatorKind::DefaultLib => format!("__rdl_{}", base),
+            AllocatorKind::DefaultExe => format!("__rde_{}", base),
+        }
+    }
+}
+
+pub enum AllocatorTy {
+    Layout,
+    Ptr,
+    ResultPtr,
+    Unit,
+    Usize,
+}
+
+pub struct AllocatorMethod {
+    pub name: &'static str,
+    pub inputs: &'static [AllocatorTy],
+    pub output: AllocatorTy,
+}
+
+pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
+    AllocatorMethod {
+        name: "alloc",
+        inputs: &[AllocatorTy::Layout],
+        output: AllocatorTy::ResultPtr,
+    },
+    AllocatorMethod {
+        name: "dealloc",
+        inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout],
+        output: AllocatorTy::Unit,
+    },
+    AllocatorMethod {
+        name: "realloc",
+        inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Usize],
+        output: AllocatorTy::ResultPtr,
+    },
+    AllocatorMethod {
+        name: "alloc_zeroed",
+        inputs: &[AllocatorTy::Layout],
+        output: AllocatorTy::ResultPtr,
+    },
+];
+
+pub fn global_allocator_spans(krate: &ast::Crate) -> Vec<Span> {
+    struct Finder { name: Symbol, spans: Vec<Span> }
+    impl<'ast> visit::Visitor<'ast> for Finder {
+        fn visit_item(&mut self, item: &'ast ast::Item) {
+            if item.ident.name == self.name &&
+               attr::contains_name(&item.attrs, sym::rustc_std_internal_symbol) {
+                self.spans.push(item.span);
+            }
+            visit::walk_item(self, item)
+        }
+    }
+
+    let name = Symbol::intern(&AllocatorKind::Global.fn_name("alloc"));
+    let mut f = Finder { name, spans: Vec::new() };
+    visit::walk_crate(&mut f, krate);
+    f.spans
+}
diff --git a/src/libsyntax/expand/mod.rs b/src/libsyntax/expand/mod.rs
new file mode 100644 (file)
index 0000000..038f602
--- /dev/null
@@ -0,0 +1,21 @@
+//! Definitions shared by macros / syntax extensions and e.g. librustc.
+
+use crate::ast::Attribute;
+use syntax_pos::symbol::sym;
+
+pub mod allocator;
+
+bitflags::bitflags! {
+    /// Built-in derives that need some extra tracking beyond the usual macro functionality.
+    #[derive(Default)]
+    pub struct SpecialDerives: u8 {
+        const PARTIAL_EQ = 1 << 0;
+        const EQ         = 1 << 1;
+        const COPY       = 1 << 2;
+    }
+}
+
+pub fn is_proc_macro_attr(attr: &Attribute) -> bool {
+    [sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive]
+        .iter().any(|kind| attr.check_name(*kind))
+}
index 3a2af96f7db6483bb8bdd84c8dac9dac77df9ede..7be6e6c7e1876ecad9015494c3d6763b040e7831 100644 (file)
@@ -95,9 +95,9 @@ pub mod util {
 
 pub mod ast;
 pub mod attr;
+pub mod expand;
 pub mod source_map;
-#[macro_use]
-pub mod config;
+#[macro_use] pub mod config;
 pub mod entry;
 pub mod feature_gate;
 pub mod mut_visit;
index e6ddf8778ccf035dbd8f095f45f8d15a784c081b..f5e416b722bbf01a161a01da9da60d9c4ad740a3 100644 (file)
@@ -288,6 +288,27 @@ pub fn stream_to_parser_with_base_dir<'a>(
     Parser::new(sess, stream, Some(base_dir), true, false, None)
 }
 
+/// Runs the given subparser `f` on the tokens of the given `attr`'s item.
+pub fn parse_in_attr<'a, T>(
+    sess: &'a ParseSess,
+    attr: &ast::Attribute,
+    mut f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>,
+) -> PResult<'a, T> {
+    let mut parser = Parser::new(
+        sess,
+        attr.tokens.clone(),
+        None,
+        false,
+        false,
+        Some("attribute"),
+    );
+    let result = f(&mut parser)?;
+    if parser.token != token::Eof {
+        parser.unexpected()?;
+    }
+    Ok(result)
+}
+
 // NOTE(Centril): The following probably shouldn't be here but it acknowledges the
 // fact that architecturally, we are using parsing (read on below to understand why).
 
index 77709a2295339fb5ac5765852f451004090fac45..38a28224daba44d5c028aed686a5421f92e38f56 100644 (file)
@@ -130,7 +130,7 @@ fn parse_path_allowing_meta(&mut self, style: PathStyle) -> PResult<'a, Path> {
     }
 
     /// Parse a list of paths inside `#[derive(path_0, ..., path_n)]`.
-    crate fn parse_derive_paths(&mut self) -> PResult<'a, Vec<Path>> {
+    pub fn parse_derive_paths(&mut self) -> PResult<'a, Vec<Path>> {
         self.expect(&token::OpenDelim(token::Paren))?;
         let mut list = Vec::new();
         while !self.eat(&token::CloseDelim(token::Paren)) {
diff --git a/src/libsyntax_expand/allocator.rs b/src/libsyntax_expand/allocator.rs
deleted file mode 100644 (file)
index 3526be1..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-use syntax::{ast, attr, visit};
-use syntax::symbol::{sym, Symbol};
-use syntax_pos::Span;
-
-#[derive(Clone, Copy)]
-pub enum AllocatorKind {
-    Global,
-    DefaultLib,
-    DefaultExe,
-}
-
-impl AllocatorKind {
-    pub fn fn_name(&self, base: &str) -> String {
-        match *self {
-            AllocatorKind::Global => format!("__rg_{}", base),
-            AllocatorKind::DefaultLib => format!("__rdl_{}", base),
-            AllocatorKind::DefaultExe => format!("__rde_{}", base),
-        }
-    }
-}
-
-pub enum AllocatorTy {
-    Layout,
-    Ptr,
-    ResultPtr,
-    Unit,
-    Usize,
-}
-
-pub struct AllocatorMethod {
-    pub name: &'static str,
-    pub inputs: &'static [AllocatorTy],
-    pub output: AllocatorTy,
-}
-
-pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
-    AllocatorMethod {
-        name: "alloc",
-        inputs: &[AllocatorTy::Layout],
-        output: AllocatorTy::ResultPtr,
-    },
-    AllocatorMethod {
-        name: "dealloc",
-        inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout],
-        output: AllocatorTy::Unit,
-    },
-    AllocatorMethod {
-        name: "realloc",
-        inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Usize],
-        output: AllocatorTy::ResultPtr,
-    },
-    AllocatorMethod {
-        name: "alloc_zeroed",
-        inputs: &[AllocatorTy::Layout],
-        output: AllocatorTy::ResultPtr,
-    },
-];
-
-pub fn global_allocator_spans(krate: &ast::Crate) -> Vec<Span> {
-    struct Finder { name: Symbol, spans: Vec<Span> }
-    impl<'ast> visit::Visitor<'ast> for Finder {
-        fn visit_item(&mut self, item: &'ast ast::Item) {
-            if item.ident.name == self.name &&
-               attr::contains_name(&item.attrs, sym::rustc_std_internal_symbol) {
-                self.spans.push(item.span);
-            }
-            visit::walk_item(self, item)
-        }
-    }
-
-    let name = Symbol::intern(&AllocatorKind::Global.fn_name("alloc"));
-    let mut f = Finder { name, spans: Vec::new() };
-    visit::walk_crate(&mut f, krate);
-    f.spans
-}
index 58edf23a5b1e2be2dadb7e4762f0f18ce7976788..a66263a9a028a17359b20cc35517acc5062a607c 100644 (file)
@@ -1,5 +1,4 @@
 use crate::expand::{self, AstFragment, Invocation};
-use crate::hygiene::ExpnId;
 
 use syntax::ast::{self, NodeId, Attribute, Name, PatKind};
 use syntax::attr::{self, HasAttrs, Stability, Deprecation};
 use syntax::{ThinVec, MACRO_ARGUMENTS};
 use syntax::tokenstream::{self, TokenStream};
 use syntax::visit::Visitor;
+crate use syntax::expand::SpecialDerives;
 
 use errors::{DiagnosticBuilder, DiagnosticId};
 use smallvec::{smallvec, SmallVec};
 use syntax_pos::{FileName, Span, MultiSpan, DUMMY_SP};
-use syntax_pos::hygiene::{AstPass, ExpnData, ExpnKind};
+use syntax_pos::hygiene::{AstPass, ExpnId, ExpnData, ExpnKind};
 
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::sync::{self, Lrc};
@@ -27,7 +27,7 @@
 use std::rc::Rc;
 use std::default::Default;
 
-pub use syntax_pos::hygiene::MacroKind;
+crate use syntax_pos::hygiene::MacroKind;
 
 #[derive(Debug,Clone)]
 pub enum Annotatable {
@@ -837,16 +837,6 @@ pub enum InvocationRes {
 /// Error type that denotes indeterminacy.
 pub struct Indeterminate;
 
-bitflags::bitflags! {
-    /// Built-in derives that need some extra tracking beyond the usual macro functionality.
-    #[derive(Default)]
-    pub struct SpecialDerives: u8 {
-        const PARTIAL_EQ = 1 << 0;
-        const EQ         = 1 << 1;
-        const COPY       = 1 << 2;
-    }
-}
-
 pub trait Resolver {
     fn next_node_id(&mut self) -> NodeId;
 
index db292b619be39de88c7a8c31732e1b9e05c06247..10eb3ecb20bd02d542c3f8e33db66bc2ac96b12a 100644 (file)
@@ -28,9 +28,8 @@ macro_rules! panictry {
 mod placeholders;
 mod proc_macro_server;
 
-pub use syntax_pos::hygiene;
+crate use syntax_pos::hygiene;
 pub use mbe::macro_rules::compile_declarative_macro;
-pub mod allocator;
 pub mod base;
 pub mod build;
 pub mod expand;
index 07b618c99a5569d578fa28d81dd851fa2fb054ef..bda9478ce96a9ea436763014665c3afc739e1a90 100644 (file)
@@ -178,11 +178,6 @@ fn visit_attribute(&mut self, attr: &Attribute) {
     fn visit_mac(&mut self, _mac: &Mac) {}
 }
 
-pub fn is_proc_macro_attr(attr: &Attribute) -> bool {
-    [sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive]
-        .iter().any(|kind| attr.check_name(*kind))
-}
-
 crate fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec<ast::Attribute>) -> Vec<ast::Path> {
     let mut result = Vec::new();
     attrs.retain(|attr| {
@@ -200,7 +195,14 @@ pub fn is_proc_macro_attr(attr: &Attribute) -> bool {
             return false;
         }
 
-        match attr.parse_derive_paths(cx.parse_sess) {
+        let parse_derive_paths = |attr: &ast::Attribute| {
+            if attr.tokens.is_empty() {
+                return Ok(Vec::new());
+            }
+            parse::parse_in_attr(cx.parse_sess, attr, |p| p.parse_derive_paths())
+        };
+
+        match parse_derive_paths(attr) {
             Ok(traits) => {
                 result.extend(traits);
                 true
index 67ef69babdc0ac3ad99f155e9e14c3ce1c40acb9..061afa379c6e3fae402e5dd4b5c6057a935fbc70 100644 (file)
@@ -3,7 +3,8 @@
 use crate::deriving::generic::ty::*;
 
 use syntax::ast::{self, Expr, GenericArg, Generics, ItemKind, MetaItem, VariantData};
-use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives};
+use syntax::expand::SpecialDerives;
+use syntax_expand::base::{Annotatable, ExtCtxt};
 use syntax::ptr::P;
 use syntax::symbol::{kw, sym, Symbol};
 use syntax_pos::Span;
index 162aaedafea325c9fd04eda006887657375c0894..eddf8eea1db32f779767d21c730eefcdb70b8970 100644 (file)
@@ -3,9 +3,10 @@
 use crate::deriving::generic::ty::*;
 
 use syntax::ast::{self, Ident, Expr, MetaItem, GenericArg};
-use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives};
+use syntax::expand::SpecialDerives;
 use syntax::ptr::P;
 use syntax::symbol::{sym, Symbol};
+use syntax_expand::base::{Annotatable, ExtCtxt};
 use syntax_pos::Span;
 
 pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>,
index c3e2b78bbe506ccf27c211c95a62e12a355168e7..2e2be91de8a4623c7d4989a6768b4b9ccfaf0342 100644 (file)
@@ -3,10 +3,11 @@
 use crate::deriving::generic::ty::*;
 
 use syntax::ast::{BinOpKind, Expr, MetaItem};
-use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives};
+use syntax::expand::SpecialDerives;
 use syntax::ptr::P;
 use syntax::symbol::sym;
-use syntax_pos::{self, Span};
+use syntax_expand::base::{Annotatable, ExtCtxt};
+use syntax_pos::Span;
 
 pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt<'_>,
                                   span: Span,
index 216338c1a8861576790caf024eae8d72886ff7e8..c04b65245e1f7911b8f4edf09e98d0caf9f47fcf 100644 (file)
 use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind};
 use syntax::ast::{VariantData, GenericParamKind, GenericArg};
 use syntax::attr;
+use syntax::expand::SpecialDerives;
 use syntax::source_map::respan;
 use syntax::util::map_in_place::MapInPlace;
 use syntax::ptr::P;
 use syntax::sess::ParseSess;
 use syntax::symbol::{Symbol, kw, sym};
-use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives};
-use syntax_pos::{Span};
+use syntax_expand::base::{Annotatable, ExtCtxt};
+use syntax_pos::Span;
 
 use ty::{LifetimeBounds, Path, Ptr, PtrTy, Self_, Ty};
 
index 75dda9535b333c509e3808c7c8eed18e3482f745..90d2ea38bc33604f903f2cc12fc3b073918afd57 100644 (file)
@@ -2,10 +2,10 @@
 
 use syntax::ast::{ItemKind, Mutability, Stmt, Ty, TyKind, Unsafety};
 use syntax::ast::{self, Param, Attribute, Expr, FnHeader, Generics, Ident};
-use syntax_expand::allocator::{AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS};
-use syntax_expand::base::{Annotatable, ExtCtxt};
+use syntax::expand::allocator::{AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS};
 use syntax::ptr::P;
 use syntax::symbol::{kw, sym, Symbol};
+use syntax_expand::base::{Annotatable, ExtCtxt};
 use syntax_pos::Span;
 
 pub fn expand(
index c874f1ffb1175d55d3d5824f777b7a357c8295d2..fc4a7a0a0fe4729d6c469f52ef250a830dd8aa41 100644 (file)
@@ -3,6 +3,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;
@@ -10,7 +11,6 @@
 use syntax::visit::{self, Visitor};
 use syntax_expand::base::{ExtCtxt, Resolver};
 use syntax_expand::expand::{AstFragment, ExpansionConfig};
-use syntax_expand::proc_macro::is_proc_macro_attr;
 use syntax_pos::{Span, DUMMY_SP};
 use syntax_pos::hygiene::AstPass;
 
index fd27a218906989e0fba5ef20eadab939696a803b..6514ff5e252684cc2eb0f7fa4e2f1d1d560a2e44 100644 (file)
@@ -4,9 +4,9 @@
 use syntax::sess::ParseSess;
 use syntax::symbol::{Ident, Symbol, kw, sym};
 use syntax_expand::expand::ExpansionConfig;
-use syntax_expand::hygiene::AstPass;
 use syntax_expand::base::{ExtCtxt, Resolver};
 use syntax_pos::DUMMY_SP;
+use syntax_pos::hygiene::AstPass;
 
 pub fn inject(
     mut krate: ast::Crate,