about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-16 21:06:17 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-24 12:27:58 +0300
commita93fdfedf36dcb909d90cbf963b087c5873bec1d (patch)
treea6cd8127f5490298317446aa618a640316992016
parenta7f28678bbf4e16893bb6a718e427504167a9494 (diff)
downloadrust-a93fdfedf36dcb909d90cbf963b087c5873bec1d.tar.gz
rust-a93fdfedf36dcb909d90cbf963b087c5873bec1d.zip
Merge `rustc_allocator` into `libsyntax_ext`
-rw-r--r--Cargo.lock18
-rw-r--r--src/librustc/lib.rs1
-rw-r--r--src/librustc/middle/allocator.rs16
-rw-r--r--src/librustc/session/mod.rs2
-rw-r--r--src/librustc_allocator/Cargo.toml19
-rw-r--r--src/librustc_codegen_llvm/allocator.rs3
-rw-r--r--src/librustc_codegen_llvm/lib.rs3
-rw-r--r--src/librustc_codegen_ssa/Cargo.toml1
-rw-r--r--src/librustc_codegen_ssa/back/symbol_export.rs4
-rw-r--r--src/librustc_codegen_ssa/traits/backend.rs2
-rw-r--r--src/librustc_driver/Cargo.toml2
-rw-r--r--src/librustc_interface/Cargo.toml1
-rw-r--r--src/librustc_interface/passes.rs2
-rw-r--r--src/librustc_metadata/creader.rs2
-rw-r--r--src/libsyntax/ext/allocator.rs (renamed from src/librustc_allocator/lib.rs)47
-rw-r--r--src/libsyntax/lib.rs1
-rw-r--r--src/libsyntax_ext/global_allocator.rs (renamed from src/librustc_allocator/expand.rs)8
-rw-r--r--src/libsyntax_ext/lib.rs1
18 files changed, 41 insertions, 92 deletions
diff --git a/Cargo.lock b/Cargo.lock
index bdc746c0bb0..89932546278 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2752,20 +2752,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "rustc_allocator"
-version = "0.0.0"
-dependencies = [
- "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc 0.0.0",
- "rustc_data_structures 0.0.0",
- "rustc_errors 0.0.0",
- "rustc_target 0.0.0",
- "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntax 0.0.0",
- "syntax_pos 0.0.0",
-]
-
-[[package]]
 name = "rustc_apfloat"
 version = "0.0.0"
 dependencies = [
@@ -2822,7 +2808,6 @@ dependencies = [
  "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc 0.0.0",
- "rustc_allocator 0.0.0",
  "rustc_apfloat 0.0.0",
  "rustc_codegen_utils 0.0.0",
  "rustc_data_structures 0.0.0",
@@ -2883,7 +2868,6 @@ dependencies = [
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc 0.0.0",
  "rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc_allocator 0.0.0",
  "rustc_ast_borrowck 0.0.0",
  "rustc_codegen_utils 0.0.0",
  "rustc_data_structures 0.0.0",
@@ -2904,7 +2888,6 @@ dependencies = [
  "serialize 0.0.0",
  "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "syntax 0.0.0",
- "syntax_ext 0.0.0",
  "syntax_pos 0.0.0",
 ]
 
@@ -2948,7 +2931,6 @@ dependencies = [
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc 0.0.0",
  "rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc_allocator 0.0.0",
  "rustc_ast_borrowck 0.0.0",
  "rustc_codegen_ssa 0.0.0",
  "rustc_codegen_utils 0.0.0",
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index 63e0107a4d8..45c6aa63c55 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -112,7 +112,6 @@ pub mod infer;
 pub mod lint;
 
 pub mod middle {
-    pub mod allocator;
     pub mod borrowck;
     pub mod expr_use_visitor;
     pub mod cstore;
diff --git a/src/librustc/middle/allocator.rs b/src/librustc/middle/allocator.rs
deleted file mode 100644
index bb2e3b4ec19..00000000000
--- a/src/librustc/middle/allocator.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-#[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),
-        }
-    }
-}
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index 664926a152f..d7620817f04 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -7,7 +7,6 @@ use rustc_data_structures::fingerprint::Fingerprint;
 
 use crate::lint;
 use crate::lint::builtin::BuiltinLintDiagnostics;
-use crate::middle::allocator::AllocatorKind;
 use crate::middle::dependency_format;
 use crate::session::config::{OutputType, PrintRequest, SwitchWithOptPath};
 use crate::session::search_paths::{PathKind, SearchPath};
@@ -27,6 +26,7 @@ use errors::emitter::HumanReadableErrorType;
 use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
 use syntax::ast::{self, NodeId};
 use syntax::edition::Edition;
+use syntax::ext::allocator::AllocatorKind;
 use syntax::feature_gate::{self, AttributeType};
 use syntax::json::JsonEmitter;
 use syntax::source_map;
diff --git a/src/librustc_allocator/Cargo.toml b/src/librustc_allocator/Cargo.toml
deleted file mode 100644
index a964f323c9e..00000000000
--- a/src/librustc_allocator/Cargo.toml
+++ /dev/null
@@ -1,19 +0,0 @@
-[package]
-authors = ["The Rust Project Developers"]
-name = "rustc_allocator"
-version = "0.0.0"
-edition = "2018"
-
-[lib]
-path = "lib.rs"
-test = false
-
-[dependencies]
-rustc = { path = "../librustc" }
-rustc_data_structures = { path = "../librustc_data_structures" }
-rustc_errors = { path = "../librustc_errors" }
-rustc_target = { path = "../librustc_target" }
-syntax = { path = "../libsyntax" }
-syntax_pos = { path = "../libsyntax_pos" }
-log = "0.4"
-smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
diff --git a/src/librustc_codegen_llvm/allocator.rs b/src/librustc_codegen_llvm/allocator.rs
index 02a05fd1102..5d43bf6ae28 100644
--- a/src/librustc_codegen_llvm/allocator.rs
+++ b/src/librustc_codegen_llvm/allocator.rs
@@ -2,9 +2,8 @@ use std::ffi::CString;
 
 use crate::attributes;
 use libc::c_uint;
-use rustc::middle::allocator::AllocatorKind;
 use rustc::ty::TyCtxt;
-use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy};
+use syntax::ext::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
 
 use crate::ModuleLlvm;
 use crate::llvm::{self, False, True};
diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs
index 0f0b9f27917..8dd241bd81a 100644
--- a/src/librustc_codegen_llvm/lib.rs
+++ b/src/librustc_codegen_llvm/lib.rs
@@ -32,7 +32,6 @@ extern crate flate2;
 #[macro_use] extern crate bitflags;
 extern crate libc;
 #[macro_use] extern crate rustc;
-extern crate rustc_allocator;
 extern crate rustc_target;
 #[macro_use] extern crate rustc_data_structures;
 extern crate rustc_incremental;
@@ -52,13 +51,13 @@ use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinModul
 use rustc_codegen_ssa::CompiledModule;
 use errors::{FatalError, Handler};
 use rustc::dep_graph::WorkProduct;
+use syntax::ext::allocator::AllocatorKind;
 use syntax_pos::symbol::InternedString;
 pub use llvm_util::target_features;
 use std::any::Any;
 use std::sync::{mpsc, Arc};
 
 use rustc::dep_graph::DepGraph;
-use rustc::middle::allocator::AllocatorKind;
 use rustc::middle::cstore::{EncodedMetadata, MetadataLoader};
 use rustc::session::Session;
 use rustc::session::config::{OutputFilenames, OutputType, PrintRequest, OptLevel};
diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml
index e7ee06df7e1..3c51c777f53 100644
--- a/src/librustc_codegen_ssa/Cargo.toml
+++ b/src/librustc_codegen_ssa/Cargo.toml
@@ -24,7 +24,6 @@ serialize = { path = "../libserialize" }
 syntax = { path = "../libsyntax" }
 syntax_pos = { path = "../libsyntax_pos" }
 rustc = { path = "../librustc" }
-rustc_allocator = { path = "../librustc_allocator" }
 rustc_apfloat = { path = "../librustc_apfloat" }
 rustc_codegen_utils = { path = "../librustc_codegen_utils" }
 rustc_data_structures = { path = "../librustc_data_structures"}
diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs
index c5553fa93cf..2d9220f897c 100644
--- a/src/librustc_codegen_ssa/back/symbol_export.rs
+++ b/src/librustc_codegen_ssa/back/symbol_export.rs
@@ -1,3 +1,4 @@
+use std::collections::hash_map::Entry::*;
 use std::sync::Arc;
 
 use rustc::ty::Instance;
@@ -12,9 +13,8 @@ use rustc::ty::{TyCtxt, SymbolName};
 use rustc::ty::query::Providers;
 use rustc::ty::subst::SubstsRef;
 use rustc::util::nodemap::{FxHashMap, DefIdMap};
-use rustc_allocator::ALLOCATOR_METHODS;
 use rustc_data_structures::indexed_vec::IndexVec;
-use std::collections::hash_map::Entry::*;
+use syntax::ext::allocator::ALLOCATOR_METHODS;
 
 pub type ExportedSymbols = FxHashMap<
     CrateNum,
diff --git a/src/librustc_codegen_ssa/traits/backend.rs b/src/librustc_codegen_ssa/traits/backend.rs
index 9d5aaa7655d..9fbb44dcc99 100644
--- a/src/librustc_codegen_ssa/traits/backend.rs
+++ b/src/librustc_codegen_ssa/traits/backend.rs
@@ -3,12 +3,12 @@ use rustc::ty::Ty;
 
 use super::write::WriteBackendMethods;
 use super::CodegenObject;
-use rustc::middle::allocator::AllocatorKind;
 use rustc::middle::cstore::EncodedMetadata;
 use rustc::session::{Session, config};
 use rustc::ty::TyCtxt;
 use rustc_codegen_utils::codegen_backend::CodegenBackend;
 use std::sync::Arc;
+use syntax::ext::allocator::AllocatorKind;
 use syntax_pos::symbol::InternedString;
 
 pub trait BackendTypes {
diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml
index d4c30dc6c45..aafc78cf94e 100644
--- a/src/librustc_driver/Cargo.toml
+++ b/src/librustc_driver/Cargo.toml
@@ -16,7 +16,6 @@ log = "0.4"
 env_logger = { version = "0.5", default-features = false }
 rayon = { version = "0.2.0", package = "rustc-rayon" }
 rustc = { path = "../librustc" }
-rustc_allocator = { path = "../librustc_allocator" }
 rustc_target = { path = "../librustc_target" }
 rustc_ast_borrowck = { path = "../librustc_ast_borrowck" }
 rustc_data_structures = { path = "../librustc_data_structures" }
@@ -37,5 +36,4 @@ rustc_interface = { path = "../librustc_interface" }
 serialize = { path = "../libserialize" }
 syntax = { path = "../libsyntax" }
 smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
-syntax_ext = { path = "../libsyntax_ext" }
 syntax_pos = { path = "../libsyntax_pos" }
diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml
index a0efec5ee7a..44fe3ff2c9d 100644
--- a/src/librustc_interface/Cargo.toml
+++ b/src/librustc_interface/Cargo.toml
@@ -18,7 +18,6 @@ syntax_ext = { path = "../libsyntax_ext" }
 syntax_pos = { path = "../libsyntax_pos" }
 serialize = { path = "../libserialize" }
 rustc = { path = "../librustc" }
-rustc_allocator = { path = "../librustc_allocator" }
 rustc_ast_borrowck = { path = "../librustc_ast_borrowck" }
 rustc_incremental = { path = "../librustc_incremental" }
 rustc_traits = { path = "../librustc_traits" }
diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs
index 6bf56bf8515..d4a922ddd49 100644
--- a/src/librustc_interface/passes.rs
+++ b/src/librustc_interface/passes.rs
@@ -497,7 +497,7 @@ fn configure_and_expand_inner<'a>(
     if has_global_allocator {
         // Expand global allocators, which are treated as an in-tree proc macro
         time(sess, "creating allocators", || {
-            allocator::expand::modify(
+            syntax_ext::global_allocator::modify(
                 &sess.parse_sess,
                 &mut resolver,
                 &mut krate,
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs
index 126cfec157f..31f70155b4e 100644
--- a/src/librustc_metadata/creader.rs
+++ b/src/librustc_metadata/creader.rs
@@ -8,7 +8,6 @@ use rustc_data_structures::sync::{Lrc, RwLock, Lock};
 
 use rustc::hir::def_id::CrateNum;
 use rustc_data_structures::svh::Svh;
-use rustc::middle::allocator::AllocatorKind;
 use rustc::middle::cstore::DepKind;
 use rustc::mir::interpret::AllocDecodingState;
 use rustc::session::{Session, CrateDisambiguator};
@@ -26,6 +25,7 @@ use std::{cmp, fs};
 
 use syntax::ast;
 use syntax::attr;
+use syntax::ext::allocator::AllocatorKind;
 use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind};
 use syntax::symbol::{Symbol, sym};
 use syntax::visit;
diff --git a/src/librustc_allocator/lib.rs b/src/libsyntax/ext/allocator.rs
index 8d380c47bc4..f2c6bf27cee 100644
--- a/src/librustc_allocator/lib.rs
+++ b/src/libsyntax/ext/allocator.rs
@@ -1,10 +1,33 @@
-#![feature(nll)]
-#![feature(rustc_private)]
+#[derive(Clone, Copy)]
+pub enum AllocatorKind {
+    Global,
+    DefaultLib,
+    DefaultExe,
+}
 
-#![deny(rust_2018_idioms)]
-#![deny(unused_lifetimes)]
+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 mod expand;
+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 {
@@ -28,17 +51,3 @@ pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
         output: AllocatorTy::ResultPtr,
     },
 ];
-
-pub struct AllocatorMethod {
-    pub name: &'static str,
-    pub inputs: &'static [AllocatorTy],
-    pub output: AllocatorTy,
-}
-
-pub enum AllocatorTy {
-    Layout,
-    Ptr,
-    ResultPtr,
-    Unit,
-    Usize,
-}
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index 3dea1977c4d..e3bc72335ab 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -165,6 +165,7 @@ pub mod print {
 
 pub mod ext {
     pub use syntax_pos::hygiene;
+    pub mod allocator;
     pub mod base;
     pub mod build;
     pub mod derive;
diff --git a/src/librustc_allocator/expand.rs b/src/libsyntax_ext/global_allocator.rs
index af63fffc0f9..e8f94bff144 100644
--- a/src/librustc_allocator/expand.rs
+++ b/src/libsyntax_ext/global_allocator.rs
@@ -1,5 +1,4 @@
 use log::debug;
-use rustc::middle::allocator::AllocatorKind;
 use smallvec::{smallvec, SmallVec};
 use syntax::{
     ast::{
@@ -11,6 +10,7 @@ use syntax::{
         respan, ExpnInfo, ExpnKind,
     },
     ext::{
+        allocator::{AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS},
         base::{ExtCtxt, MacroKind, Resolver},
         build::AstBuilder,
         expand::ExpansionConfig,
@@ -23,14 +23,12 @@ use syntax::{
 };
 use syntax_pos::Span;
 
-use crate::{AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS};
-
 pub fn modify(
     sess: &ParseSess,
     resolver: &mut dyn Resolver,
     krate: &mut Crate,
     crate_name: String,
-    handler: &rustc_errors::Handler,
+    handler: &errors::Handler,
 ) {
     ExpandAllocatorDirectives {
         handler,
@@ -44,7 +42,7 @@ pub fn modify(
 
 struct ExpandAllocatorDirectives<'a> {
     found: bool,
-    handler: &'a rustc_errors::Handler,
+    handler: &'a errors::Handler,
     sess: &'a ParseSess,
     resolver: &'a mut dyn Resolver,
     crate_name: Option<String>,
diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs
index 7de90278ed7..cd7ac5fe2c6 100644
--- a/src/libsyntax_ext/lib.rs
+++ b/src/libsyntax_ext/lib.rs
@@ -37,6 +37,7 @@ mod test_case;
 mod trace_macros;
 
 pub mod deriving;
+pub mod global_allocator;
 pub mod proc_macro_decls;
 pub mod proc_macro_impl;