Skip to content

Commit b93d2ac

Browse files
committed
Merge rustc_allocator into libsyntax_ext
1 parent 1196dfe commit b93d2ac

File tree

16 files changed

+41
-72
lines changed

16 files changed

+41
-72
lines changed

src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ pub mod infer;
112112
pub mod lint;
113113

114114
pub mod middle {
115-
pub mod allocator;
116115
pub mod borrowck;
117116
pub mod expr_use_visitor;
118117
pub mod cstore;

src/librustc/middle/allocator.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/librustc/session/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_data_structures::fingerprint::Fingerprint;
77

88
use crate::lint;
99
use crate::lint::builtin::BuiltinLintDiagnostics;
10-
use crate::middle::allocator::AllocatorKind;
1110
use crate::middle::dependency_format;
1211
use crate::session::config::{OutputType, PrintRequest, SwitchWithOptPath};
1312
use crate::session::search_paths::{PathKind, SearchPath};
@@ -27,6 +26,7 @@ use errors::emitter::HumanReadableErrorType;
2726
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
2827
use syntax::ast::{self, NodeId};
2928
use syntax::edition::Edition;
29+
use syntax::ext::allocator::AllocatorKind;
3030
use syntax::feature_gate::{self, AttributeType};
3131
use syntax::json::JsonEmitter;
3232
use syntax::source_map;

src/librustc_allocator/Cargo.toml

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/librustc_codegen_llvm/allocator.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::ffi::CString;
22

33
use crate::attributes;
44
use libc::c_uint;
5-
use rustc::middle::allocator::AllocatorKind;
65
use rustc::ty::TyCtxt;
7-
use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy};
6+
use syntax::ext::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
87

98
use crate::ModuleLlvm;
109
use crate::llvm::{self, False, True};

src/librustc_codegen_llvm/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ extern crate flate2;
3232
#[macro_use] extern crate bitflags;
3333
extern crate libc;
3434
#[macro_use] extern crate rustc;
35-
extern crate rustc_allocator;
3635
extern crate rustc_target;
3736
#[macro_use] extern crate rustc_data_structures;
3837
extern crate rustc_incremental;
@@ -52,13 +51,13 @@ use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinModul
5251
use rustc_codegen_ssa::CompiledModule;
5352
use errors::{FatalError, Handler};
5453
use rustc::dep_graph::WorkProduct;
54+
use syntax::ext::allocator::AllocatorKind;
5555
use syntax_pos::symbol::InternedString;
5656
pub use llvm_util::target_features;
5757
use std::any::Any;
5858
use std::sync::{mpsc, Arc};
5959

6060
use rustc::dep_graph::DepGraph;
61-
use rustc::middle::allocator::AllocatorKind;
6261
use rustc::middle::cstore::{EncodedMetadata, MetadataLoader};
6362
use rustc::session::Session;
6463
use rustc::session::config::{OutputFilenames, OutputType, PrintRequest, OptLevel};

src/librustc_codegen_ssa/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ serialize = { path = "../libserialize" }
2424
syntax = { path = "../libsyntax" }
2525
syntax_pos = { path = "../libsyntax_pos" }
2626
rustc = { path = "../librustc" }
27-
rustc_allocator = { path = "../librustc_allocator" }
2827
rustc_apfloat = { path = "../librustc_apfloat" }
2928
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
3029
rustc_data_structures = { path = "../librustc_data_structures"}

src/librustc_codegen_ssa/back/symbol_export.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::collections::hash_map::Entry::*;
12
use std::sync::Arc;
23

34
use rustc::ty::Instance;
@@ -12,9 +13,8 @@ use rustc::ty::{TyCtxt, SymbolName};
1213
use rustc::ty::query::Providers;
1314
use rustc::ty::subst::SubstsRef;
1415
use rustc::util::nodemap::{FxHashMap, DefIdMap};
15-
use rustc_allocator::ALLOCATOR_METHODS;
1616
use rustc_data_structures::indexed_vec::IndexVec;
17-
use std::collections::hash_map::Entry::*;
17+
use syntax::ext::allocator::ALLOCATOR_METHODS;
1818

1919
pub type ExportedSymbols = FxHashMap<
2020
CrateNum,

src/librustc_codegen_ssa/traits/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use rustc::ty::Ty;
33

44
use super::write::WriteBackendMethods;
55
use super::CodegenObject;
6-
use rustc::middle::allocator::AllocatorKind;
76
use rustc::middle::cstore::EncodedMetadata;
87
use rustc::session::{Session, config};
98
use rustc::ty::TyCtxt;
109
use rustc_codegen_utils::codegen_backend::CodegenBackend;
1110
use std::sync::Arc;
11+
use syntax::ext::allocator::AllocatorKind;
1212
use syntax_pos::symbol::InternedString;
1313

1414
pub trait BackendTypes {

src/librustc_interface/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ syntax_ext = { path = "../libsyntax_ext" }
1818
syntax_pos = { path = "../libsyntax_pos" }
1919
serialize = { path = "../libserialize" }
2020
rustc = { path = "../librustc" }
21-
rustc_allocator = { path = "../librustc_allocator" }
2221
rustc_ast_borrowck = { path = "../librustc_ast_borrowck" }
2322
rustc_incremental = { path = "../librustc_incremental" }
2423
rustc_traits = { path = "../librustc_traits" }

src/librustc_interface/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ fn configure_and_expand_inner<'a>(
497497
if has_global_allocator {
498498
// Expand global allocators, which are treated as an in-tree proc macro
499499
time(sess, "creating allocators", || {
500-
allocator::expand::modify(
500+
syntax_ext::global_allocator::modify(
501501
&sess.parse_sess,
502502
&mut resolver,
503503
&mut krate,

src/librustc_metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_data_structures::sync::{Lrc, RwLock, Lock};
88

99
use rustc::hir::def_id::CrateNum;
1010
use rustc_data_structures::svh::Svh;
11-
use rustc::middle::allocator::AllocatorKind;
1211
use rustc::middle::cstore::DepKind;
1312
use rustc::mir::interpret::AllocDecodingState;
1413
use rustc::session::{Session, CrateDisambiguator};
@@ -26,6 +25,7 @@ use std::{cmp, fs};
2625

2726
use syntax::ast;
2827
use syntax::attr;
28+
use syntax::ext::allocator::AllocatorKind;
2929
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind};
3030
use syntax::symbol::{Symbol, sym};
3131
use syntax::visit;

src/librustc_allocator/lib.rs renamed to src/libsyntax/ext/allocator.rs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
1-
#![feature(nll)]
2-
#![feature(rustc_private)]
1+
#[derive(Clone, Copy)]
2+
pub enum AllocatorKind {
3+
Global,
4+
DefaultLib,
5+
DefaultExe,
6+
}
37

4-
#![deny(rust_2018_idioms)]
5-
#![deny(unused_lifetimes)]
8+
impl AllocatorKind {
9+
pub fn fn_name(&self, base: &str) -> String {
10+
match *self {
11+
AllocatorKind::Global => format!("__rg_{}", base),
12+
AllocatorKind::DefaultLib => format!("__rdl_{}", base),
13+
AllocatorKind::DefaultExe => format!("__rde_{}", base),
14+
}
15+
}
16+
}
617

7-
pub mod expand;
18+
pub enum AllocatorTy {
19+
Layout,
20+
Ptr,
21+
ResultPtr,
22+
Unit,
23+
Usize,
24+
}
25+
26+
pub struct AllocatorMethod {
27+
pub name: &'static str,
28+
pub inputs: &'static [AllocatorTy],
29+
pub output: AllocatorTy,
30+
}
831

932
pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
1033
AllocatorMethod {
@@ -28,17 +51,3 @@ pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
2851
output: AllocatorTy::ResultPtr,
2952
},
3053
];
31-
32-
pub struct AllocatorMethod {
33-
pub name: &'static str,
34-
pub inputs: &'static [AllocatorTy],
35-
pub output: AllocatorTy,
36-
}
37-
38-
pub enum AllocatorTy {
39-
Layout,
40-
Ptr,
41-
ResultPtr,
42-
Unit,
43-
Usize,
44-
}

src/libsyntax/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ pub mod ext {
171171
mod proc_macro_server;
172172

173173
pub use syntax_pos::hygiene;
174+
pub mod allocator;
174175
pub mod base;
175176
pub mod build;
176177
pub mod expand;

src/librustc_allocator/expand.rs renamed to src/libsyntax_ext/global_allocator.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use log::debug;
2-
use rustc::middle::allocator::AllocatorKind;
32
use smallvec::{smallvec, SmallVec};
43
use syntax::{
54
ast::{
@@ -11,6 +10,7 @@ use syntax::{
1110
respan, ExpnInfo, ExpnKind,
1211
},
1312
ext::{
13+
allocator::{AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS},
1414
base::{ExtCtxt, MacroKind, Resolver},
1515
build::AstBuilder,
1616
expand::ExpansionConfig,
@@ -23,14 +23,12 @@ use syntax::{
2323
};
2424
use syntax_pos::Span;
2525

26-
use crate::{AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS};
27-
2826
pub fn modify(
2927
sess: &ParseSess,
3028
resolver: &mut dyn Resolver,
3129
krate: &mut Crate,
3230
crate_name: String,
33-
handler: &rustc_errors::Handler,
31+
handler: &errors::Handler,
3432
) {
3533
ExpandAllocatorDirectives {
3634
handler,
@@ -44,7 +42,7 @@ pub fn modify(
4442

4543
struct ExpandAllocatorDirectives<'a> {
4644
found: bool,
47-
handler: &'a rustc_errors::Handler,
45+
handler: &'a errors::Handler,
4846
sess: &'a ParseSess,
4947
resolver: &'a mut dyn Resolver,
5048
crate_name: Option<String>,

src/libsyntax_ext/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ mod source_util;
3030
mod test;
3131
mod trace_macros;
3232

33+
pub mod global_allocator;
3334
pub mod proc_macro_decls;
3435
pub mod test_harness;
3536

0 commit comments

Comments
 (0)