Skip to content

Commit 94d9558

Browse files
authored
Rollup merge of #65465 - Centril:split-syntax-1, r=petrochenkov
Move syntax::ext to a syntax_expand and refactor some attribute logic Part of #65324. r? @petrochenkov
2 parents 2fef053 + 8ca16dd commit 94d9558

File tree

124 files changed

+709
-600
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+709
-600
lines changed

Cargo.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,6 +3112,7 @@ dependencies = [
31123112
"serialize",
31133113
"smallvec",
31143114
"syntax",
3115+
"syntax_expand",
31153116
"syntax_pos",
31163117
]
31173118

@@ -3427,6 +3428,7 @@ dependencies = [
34273428
"rustc_target",
34283429
"serialize",
34293430
"syntax",
3431+
"syntax_expand",
34303432
"syntax_pos",
34313433
"tempfile",
34323434
]
@@ -3559,6 +3561,7 @@ dependencies = [
35593561
"serialize",
35603562
"smallvec",
35613563
"syntax",
3564+
"syntax_expand",
35623565
"syntax_ext",
35633566
"syntax_pos",
35643567
"tempfile",
@@ -3630,6 +3633,7 @@ dependencies = [
36303633
"smallvec",
36313634
"stable_deref_trait",
36323635
"syntax",
3636+
"syntax_expand",
36333637
"syntax_pos",
36343638
]
36353639

@@ -3678,6 +3682,7 @@ dependencies = [
36783682
"rustc_index",
36793683
"rustc_target",
36803684
"syntax",
3685+
"syntax_expand",
36813686
"syntax_pos",
36823687
]
36833688

@@ -3695,6 +3700,7 @@ dependencies = [
36953700
"rustc",
36963701
"rustc_metadata",
36973702
"syntax",
3703+
"syntax_expand",
36983704
"syntax_pos",
36993705
]
37003706

@@ -3723,6 +3729,7 @@ dependencies = [
37233729
"rustc_metadata",
37243730
"smallvec",
37253731
"syntax",
3732+
"syntax_expand",
37263733
"syntax_pos",
37273734
]
37283735

@@ -4336,6 +4343,25 @@ dependencies = [
43364343
"syntax_pos",
43374344
]
43384345

4346+
[[package]]
4347+
name = "syntax_expand"
4348+
version = "0.0.0"
4349+
dependencies = [
4350+
"bitflags",
4351+
"lazy_static 1.3.0",
4352+
"log",
4353+
"rustc_data_structures",
4354+
"rustc_errors",
4355+
"rustc_index",
4356+
"rustc_lexer",
4357+
"rustc_target",
4358+
"scoped-tls",
4359+
"serialize",
4360+
"smallvec",
4361+
"syntax",
4362+
"syntax_pos",
4363+
]
4364+
43394365
[[package]]
43404366
name = "syntax_ext"
43414367
version = "0.0.0"
@@ -4347,6 +4373,7 @@ dependencies = [
43474373
"rustc_target",
43484374
"smallvec",
43494375
"syntax",
4376+
"syntax_expand",
43504377
"syntax_pos",
43514378
]
43524379

src/librustc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ rustc_index = { path = "../librustc_index" }
2929
errors = { path = "../librustc_errors", package = "rustc_errors" }
3030
rustc_serialize = { path = "../libserialize", package = "serialize" }
3131
syntax = { path = "../libsyntax" }
32+
syntax_expand = { path = "../libsyntax_expand" }
3233
syntax_pos = { path = "../libsyntax_pos" }
3334
backtrace = "0.3.3"
3435
parking_lot = "0.9"

src/librustc/hir/def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::ty;
66
use crate::util::nodemap::DefIdMap;
77

88
use syntax::ast;
9-
use syntax::ext::base::MacroKind;
9+
use syntax_expand::base::MacroKind;
1010
use syntax::ast::NodeId;
1111
use syntax_pos::Span;
1212
use rustc_macros::HashStable;

src/librustc/hir/lowering.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ use syntax::ast;
6464
use syntax::ptr::P as AstP;
6565
use syntax::ast::*;
6666
use syntax::errors;
67-
use syntax::ext::base::SpecialDerives;
68-
use syntax::ext::hygiene::ExpnId;
67+
use syntax_expand::base::SpecialDerives;
6968
use syntax::print::pprust;
70-
use syntax::tokenstream::{TokenStream, TokenTree};
7169
use syntax::parse::token::{self, Nonterminal, Token};
70+
use syntax::tokenstream::{TokenStream, TokenTree};
7271
use syntax::sess::ParseSess;
7372
use syntax::source_map::{respan, ExpnData, ExpnKind, DesugaringKind, Spanned};
7473
use syntax::symbol::{kw, sym, Symbol};
7574
use syntax::visit::{self, Visitor};
75+
use syntax_pos::hygiene::ExpnId;
7676
use syntax_pos::Span;
7777

7878
const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF;

src/librustc/hir/lowering/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use smallvec::SmallVec;
1818
use syntax::attr;
1919
use syntax::ast::*;
2020
use syntax::visit::{self, Visitor};
21-
use syntax::ext::base::SpecialDerives;
21+
use syntax_expand::base::SpecialDerives;
2222
use syntax::source_map::{respan, DesugaringKind, Spanned};
2323
use syntax::symbol::{kw, sym};
2424
use syntax_pos::Span;

src/librustc/hir/map/def_collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::hir::map::definitions::*;
22
use crate::hir::def_id::DefIndex;
33

44
use syntax::ast::*;
5-
use syntax::ext::hygiene::ExpnId;
5+
use syntax_expand::hygiene::ExpnId;
66
use syntax::visit;
77
use syntax::symbol::{kw, sym};
88
use syntax::parse::token::{self, Token};

src/librustc/hir/map/definitions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::borrow::Borrow;
1717
use std::fmt::Write;
1818
use std::hash::Hash;
1919
use syntax::ast;
20-
use syntax::ext::hygiene::ExpnId;
20+
use syntax_expand::hygiene::ExpnId;
2121
use syntax::symbol::{Symbol, sym, InternedString};
2222
use syntax_pos::{Span, DUMMY_SP};
2323

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_data_structures::svh::Svh;
2020
use rustc_index::vec::IndexVec;
2121
use syntax::ast::{self, Name, NodeId};
2222
use syntax::source_map::Spanned;
23-
use syntax::ext::base::MacroKind;
23+
use syntax_expand::base::MacroKind;
2424
use syntax_pos::{Span, DUMMY_SP};
2525

2626
pub mod blocks;

src/librustc/ich/hcx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::cell::RefCell;
1313

1414
use syntax::ast;
1515
use syntax::source_map::SourceMap;
16-
use syntax::ext::hygiene::SyntaxContext;
16+
use syntax_expand::hygiene::SyntaxContext;
1717
use syntax::symbol::Symbol;
1818
use syntax::tokenstream::DelimSpan;
1919
use syntax_pos::{Span, DUMMY_SP};

src/librustc/ich/impls_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl_stable_hash_for!(enum ::syntax::ast::AsmDialect {
5959
Intel
6060
});
6161

62-
impl_stable_hash_for!(enum ::syntax::ext::base::MacroKind {
62+
impl_stable_hash_for!(enum ::syntax_expand::base::MacroKind {
6363
Bang,
6464
Attr,
6565
Derive,

src/librustc/lint/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use syntax::ast;
3939
use syntax::source_map::{MultiSpan, ExpnKind, DesugaringKind};
4040
use syntax::early_buffered_lints::BufferedEarlyLintId;
4141
use syntax::edition::Edition;
42-
use syntax::ext::base::MacroKind;
42+
use syntax_expand::base::MacroKind;
4343
use syntax::symbol::{Symbol, sym};
4444
use syntax_pos::Span;
4545

src/librustc/session/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use errors::emitter::HumanReadableErrorType;
2424
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
2525
use syntax::ast::{self, NodeId};
2626
use syntax::edition::Edition;
27-
use syntax::ext::allocator::AllocatorKind;
27+
use syntax_expand::allocator::AllocatorKind;
2828
use syntax::feature_gate::{self, AttributeType};
2929
use syntax::json::JsonEmitter;
3030
use syntax::source_map;

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use std::{mem, ptr};
4545
use std::ops::Range;
4646
use syntax::ast::{self, Name, Ident, NodeId};
4747
use syntax::attr;
48-
use syntax::ext::hygiene::ExpnId;
48+
use syntax_expand::hygiene::ExpnId;
4949
use syntax::symbol::{kw, sym, Symbol, InternedString};
5050
use syntax_pos::Span;
5151

src/librustc_codegen_llvm/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::ffi::CString;
33
use crate::attributes;
44
use libc::c_uint;
55
use rustc::ty::TyCtxt;
6-
use syntax::ext::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
6+
use syntax_expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
77

88
use crate::ModuleLlvm;
99
use crate::llvm::{self, False, True};

src/librustc_codegen_llvm/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ extern crate rustc_driver as _;
3939

4040
#[macro_use] extern crate log;
4141
extern crate syntax;
42+
extern crate syntax_expand;
4243
extern crate syntax_pos;
4344
extern crate rustc_errors as errors;
4445

@@ -48,7 +49,7 @@ use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinModul
4849
use rustc_codegen_ssa::CompiledModule;
4950
use errors::{FatalError, Handler};
5051
use rustc::dep_graph::WorkProduct;
51-
use syntax::ext::allocator::AllocatorKind;
52+
use syntax_expand::allocator::AllocatorKind;
5253
use syntax_pos::symbol::InternedString;
5354
pub use llvm_util::target_features;
5455
use std::any::Any;

src/librustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tempfile = "3.1"
2121

2222
rustc_serialize = { path = "../libserialize", package = "serialize" }
2323
syntax = { path = "../libsyntax" }
24+
syntax_expand = { path = "../libsyntax_expand" }
2425
syntax_pos = { path = "../libsyntax_pos" }
2526
rustc = { path = "../librustc" }
2627
rustc_apfloat = { path = "../librustc_apfloat" }

src/librustc_codegen_ssa/back/symbol_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc::ty::query::Providers;
1414
use rustc::ty::subst::SubstsRef;
1515
use rustc::util::nodemap::{FxHashMap, DefIdMap};
1616
use rustc_index::vec::IndexVec;
17-
use syntax::ext::allocator::ALLOCATOR_METHODS;
17+
use syntax_expand::allocator::ALLOCATOR_METHODS;
1818

1919
pub type ExportedSymbols = FxHashMap<
2020
CrateNum,

src/librustc_codegen_ssa/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc_errors::{Handler, Level, FatalError, DiagnosticId, SourceMapperDyn};
2727
use rustc_errors::emitter::{Emitter};
2828
use rustc_target::spec::MergeFunctions;
2929
use syntax::attr;
30-
use syntax::ext::hygiene::ExpnId;
30+
use syntax_expand::hygiene::ExpnId;
3131
use syntax_pos::symbol::{Symbol, sym};
3232
use jobserver::{Client, Acquired};
3333

src/librustc_codegen_ssa/traits/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc::ty::TyCtxt;
99
use rustc_codegen_utils::codegen_backend::CodegenBackend;
1010
use std::sync::Arc;
1111
use std::sync::mpsc;
12-
use syntax::ext::allocator::AllocatorKind;
12+
use syntax_expand::allocator::AllocatorKind;
1313
use syntax_pos::symbol::InternedString;
1414

1515
pub trait BackendTypes {

src/librustc_interface/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ rayon = { version = "0.3.0", package = "rustc-rayon" }
1515
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
1616
syntax = { path = "../libsyntax" }
1717
syntax_ext = { path = "../libsyntax_ext" }
18+
syntax_expand = { path = "../libsyntax_expand" }
1819
syntax_pos = { path = "../libsyntax_pos" }
1920
rustc_serialize = { path = "../libserialize", package = "serialize" }
2021
rustc = { path = "../librustc" }

src/librustc_interface/passes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use rustc_traits;
3535
use rustc_typeck as typeck;
3636
use syntax::{self, ast, visit};
3737
use syntax::early_buffered_lints::BufferedEarlyLint;
38-
use syntax::ext::base::{NamedSyntaxExtension, ExtCtxt};
38+
use syntax_expand::base::{NamedSyntaxExtension, ExtCtxt};
3939
use syntax::mut_visit::MutVisitor;
4040
use syntax::parse::{self, PResult};
4141
use syntax::util::node_count::NodeCounter;
@@ -397,12 +397,12 @@ fn configure_and_expand_inner<'a>(
397397

398398
// Create the config for macro expansion
399399
let features = sess.features_untracked();
400-
let cfg = syntax::ext::expand::ExpansionConfig {
400+
let cfg = syntax_expand::expand::ExpansionConfig {
401401
features: Some(&features),
402402
recursion_limit: *sess.recursion_limit.get(),
403403
trace_mac: sess.opts.debugging_opts.trace_macros,
404404
should_test: sess.opts.test,
405-
..syntax::ext::expand::ExpansionConfig::default(crate_name.to_string())
405+
..syntax_expand::expand::ExpansionConfig::default(crate_name.to_string())
406406
};
407407

408408
let mut ecx = ExtCtxt::new(&sess.parse_sess, cfg, &mut resolver);
@@ -559,7 +559,7 @@ pub fn lower_to_hir(
559559

560560
// Discard hygiene data, which isn't required after lowering to HIR.
561561
if !sess.opts.debugging_opts.keep_hygiene_data {
562-
syntax::ext::hygiene::clear_syntax_context_map();
562+
syntax_expand::hygiene::clear_syntax_context_map();
563563
}
564564

565565
Ok(hir_forest)

src/librustc_metadata/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ rustc_index = { path = "../librustc_index" }
2222
rustc_serialize = { path = "../libserialize", package = "serialize" }
2323
stable_deref_trait = "1.0.0"
2424
syntax = { path = "../libsyntax" }
25+
syntax_expand = { path = "../libsyntax_expand" }
2526
syntax_pos = { path = "../libsyntax_pos" }

src/librustc_metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::{cmp, fs};
2626

2727
use syntax::ast;
2828
use syntax::attr;
29-
use syntax::ext::allocator::{global_allocator_spans, AllocatorKind};
29+
use syntax_expand::allocator::{global_allocator_spans, AllocatorKind};
3030
use syntax::symbol::{Symbol, sym};
3131
use syntax::{span_err, span_fatal};
3232
use syntax_pos::{Span, DUMMY_SP};

src/librustc_metadata/cstore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_index::vec::IndexVec;
1111
use rustc::util::nodemap::FxHashMap;
1212
use rustc_data_structures::sync::{Lrc, RwLock, Lock, MetadataRef, AtomicCell};
1313
use syntax::ast;
14-
use syntax::ext::base::SyntaxExtension;
14+
use syntax_expand::base::SyntaxExtension;
1515
use syntax_pos;
1616
use proc_macro::bridge::client::ProcMacro;
1717

src/librustc_metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ use syntax::attr;
3232
use syntax::ast::{self, Ident};
3333
use syntax::source_map::{self, respan, Spanned};
3434
use syntax::symbol::{Symbol, sym};
35-
use syntax::ext::base::{MacroKind, SyntaxExtensionKind, SyntaxExtension};
35+
use syntax_expand::base::{MacroKind, SyntaxExtensionKind, SyntaxExtension};
3636
use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, symbol::{InternedString}};
3737
use log::debug;
3838
use proc_macro::bridge::client::ProcMacro;
39-
use syntax::ext::proc_macro::{AttrProcMacro, ProcMacroDerive, BangProcMacro};
39+
use syntax_expand::proc_macro::{AttrProcMacro, ProcMacroDerive, BangProcMacro};
4040

4141
crate struct DecodeContext<'a, 'tcx> {
4242
opaque: opaque::Decoder<'a>,

src/librustc_metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_data_structures::sync::Lrc;
3131
use std::u32;
3232
use syntax::ast;
3333
use syntax::attr;
34-
use syntax::ext::proc_macro::is_proc_macro_attr;
34+
use syntax_expand::proc_macro::is_proc_macro_attr;
3535
use syntax::source_map::Spanned;
3636
use syntax::symbol::{kw, sym, Ident, Symbol};
3737
use syntax_pos::{self, FileName, SourceFile, Span};

src/librustc_passes/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ log = "0.4"
1313
rustc = { path = "../librustc" }
1414
rustc_data_structures = { path = "../librustc_data_structures" }
1515
syntax = { path = "../libsyntax" }
16+
syntax_expand = { path = "../libsyntax_expand" }
1617
syntax_pos = { path = "../libsyntax_pos" }
1718
errors = { path = "../librustc_errors", package = "rustc_errors" }
1819
rustc_target = { path = "../librustc_target" }

src/librustc_passes/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc::session::Session;
1414
use rustc_data_structures::fx::FxHashMap;
1515
use syntax::ast::*;
1616
use syntax::attr;
17-
use syntax::ext::proc_macro::is_proc_macro_attr;
17+
use syntax_expand::proc_macro::is_proc_macro_attr;
1818
use syntax::feature_gate::is_builtin_attr;
1919
use syntax::source_map::Spanned;
2020
use syntax::symbol::{kw, sym};

src/librustc_plugin/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ doctest = false
1414
rustc = { path = "../librustc" }
1515
rustc_metadata = { path = "../librustc_metadata" }
1616
syntax = { path = "../libsyntax" }
17+
syntax_expand = { path = "../libsyntax_expand" }
1718
syntax_pos = { path = "../libsyntax_pos" }

src/librustc_plugin/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! extern crate syntax_pos;
2222
//!
2323
//! use rustc_driver::plugin::Registry;
24-
//! use syntax::ext::base::{ExtCtxt, MacResult};
24+
//! use syntax_expand::base::{ExtCtxt, MacResult};
2525
//! use syntax_pos::Span;
2626
//! use syntax::tokenstream::TokenTree;
2727
//!

src/librustc_plugin/registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use rustc::lint::{EarlyLintPassObject, LateLintPassObject, LintId, Lint};
44
use rustc::session::Session;
55
use rustc::util::nodemap::FxHashMap;
66

7-
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind, NamedSyntaxExtension};
8-
use syntax::ext::base::MacroExpanderFn;
7+
use syntax_expand::base::{SyntaxExtension, SyntaxExtensionKind, NamedSyntaxExtension};
8+
use syntax_expand::base::MacroExpanderFn;
99
use syntax::symbol::Symbol;
1010
use syntax::ast;
1111
use syntax::feature_gate::AttributeType;

0 commit comments

Comments
 (0)