Skip to content

Commit 4ae2728

Browse files
committed
move syntax::parse -> librustc_parse
also move MACRO_ARGUMENTS -> librustc_parse
1 parent be023eb commit 4ae2728

Some content is hidden

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

67 files changed

+480
-424
lines changed

Diff for: Cargo.lock

+22-4
Original file line numberDiff line numberDiff line change
@@ -3504,6 +3504,7 @@ dependencies = [
35043504
"rustc_lint",
35053505
"rustc_metadata",
35063506
"rustc_mir",
3507+
"rustc_parse",
35073508
"rustc_plugin",
35083509
"rustc_plugin_impl",
35093510
"rustc_save_analysis",
@@ -3571,6 +3572,7 @@ dependencies = [
35713572
"rustc_lint",
35723573
"rustc_metadata",
35733574
"rustc_mir",
3575+
"rustc_parse",
35743576
"rustc_passes",
35753577
"rustc_plugin_impl",
35763578
"rustc_privacy",
@@ -3648,6 +3650,7 @@ dependencies = [
36483650
"rustc_data_structures",
36493651
"rustc_errors",
36503652
"rustc_index",
3653+
"rustc_parse",
36513654
"rustc_target",
36523655
"serialize",
36533656
"smallvec 1.0.0",
@@ -3691,6 +3694,21 @@ dependencies = [
36913694
"core",
36923695
]
36933696

3697+
[[package]]
3698+
name = "rustc_parse"
3699+
version = "0.0.0"
3700+
dependencies = [
3701+
"bitflags",
3702+
"log",
3703+
"rustc_data_structures",
3704+
"rustc_errors",
3705+
"rustc_lexer",
3706+
"rustc_target",
3707+
"smallvec 1.0.0",
3708+
"syntax",
3709+
"syntax_pos",
3710+
]
3711+
36943712
[[package]]
36953713
name = "rustc_passes"
36963714
version = "0.0.0"
@@ -3700,6 +3718,7 @@ dependencies = [
37003718
"rustc_data_structures",
37013719
"rustc_errors",
37023720
"rustc_index",
3721+
"rustc_parse",
37033722
"rustc_target",
37043723
"syntax",
37053724
"syntax_pos",
@@ -3762,6 +3781,7 @@ dependencies = [
37623781
"rustc",
37633782
"rustc_codegen_utils",
37643783
"rustc_data_structures",
3784+
"rustc_parse",
37653785
"serde_json",
37663786
"syntax",
37673787
"syntax_pos",
@@ -4371,14 +4391,11 @@ dependencies = [
43714391
name = "syntax_expand"
43724392
version = "0.0.0"
43734393
dependencies = [
4374-
"bitflags",
4375-
"lazy_static 1.3.0",
43764394
"log",
43774395
"rustc_data_structures",
43784396
"rustc_errors",
4379-
"rustc_index",
43804397
"rustc_lexer",
4381-
"scoped-tls",
4398+
"rustc_parse",
43824399
"serialize",
43834400
"smallvec 1.0.0",
43844401
"syntax",
@@ -4393,6 +4410,7 @@ dependencies = [
43934410
"log",
43944411
"rustc_data_structures",
43954412
"rustc_errors",
4413+
"rustc_parse",
43964414
"rustc_target",
43974415
"smallvec 1.0.0",
43984416
"syntax",

Diff for: src/librustc_driver/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ rustc_data_structures = { path = "../librustc_data_structures" }
2121
errors = { path = "../librustc_errors", package = "rustc_errors" }
2222
rustc_metadata = { path = "../librustc_metadata" }
2323
rustc_mir = { path = "../librustc_mir" }
24+
rustc_parse = { path = "../librustc_parse" }
2425
rustc_plugin = { path = "../librustc_plugin/deprecated" } # To get this in the sysroot
2526
rustc_plugin_impl = { path = "../librustc_plugin" }
2627
rustc_save_analysis = { path = "../librustc_save_analysis" }

Diff for: src/librustc_driver/lib.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ use std::time::Instant;
6565
use syntax::ast;
6666
use syntax::source_map::FileLoader;
6767
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
68-
use syntax::parse;
6968
use syntax::symbol::sym;
7069
use syntax_pos::{DUMMY_SP, FileName};
7170

@@ -1096,14 +1095,16 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
10961095
}
10971096

10981097
fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<ast::Attribute>> {
1099-
match *input {
1100-
Input::File(ref ifile) => {
1101-
parse::parse_crate_attrs_from_file(ifile, &sess.parse_sess)
1098+
match input {
1099+
Input::File(ifile) => {
1100+
rustc_parse::parse_crate_attrs_from_file(ifile, &sess.parse_sess)
11021101
}
1103-
Input::Str { ref name, ref input } => {
1104-
parse::parse_crate_attrs_from_source_str(name.clone(),
1105-
input.clone(),
1106-
&sess.parse_sess)
1102+
Input::Str { name, input } => {
1103+
rustc_parse::parse_crate_attrs_from_source_str(
1104+
name.clone(),
1105+
input.clone(),
1106+
&sess.parse_sess,
1107+
)
11071108
}
11081109
}
11091110
}

Diff for: src/librustc_interface/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ smallvec = { version = "1.0", features = ["union", "may_dangle"] }
1616
syntax = { path = "../libsyntax" }
1717
syntax_ext = { path = "../libsyntax_ext" }
1818
syntax_expand = { path = "../libsyntax_expand" }
19+
rustc_parse = { path = "../librustc_parse" }
1920
syntax_pos = { path = "../libsyntax_pos" }
2021
rustc_serialize = { path = "../libserialize", package = "serialize" }
2122
rustc = { path = "../librustc" }

Diff for: src/librustc_interface/interface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use rustc_codegen_utils::codegen_backend::CodegenBackend;
1111
use rustc_data_structures::OnDrop;
1212
use rustc_data_structures::sync::Lrc;
1313
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
14+
use rustc_parse::new_parser_from_source_str;
1415
use std::path::PathBuf;
1516
use std::result;
1617
use std::sync::{Arc, Mutex};
1718
use syntax::ast::{self, MetaItemKind};
18-
use syntax::parse::new_parser_from_source_str;
1919
use syntax::token;
2020
use syntax::source_map::{FileName, FileLoader, SourceMap};
2121
use syntax::sess::ParseSess;

Diff for: src/librustc_interface/passes.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use rustc_errors::PResult;
2626
use rustc_incremental;
2727
use rustc_metadata::cstore;
2828
use rustc_mir as mir;
29+
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str};
2930
use rustc_passes::{self, ast_validation, hir_stats, layout_test};
3031
use rustc_plugin as plugin;
3132
use rustc_plugin::registry::Registry;
@@ -37,7 +38,6 @@ use syntax::{self, ast, visit};
3738
use syntax::early_buffered_lints::BufferedEarlyLint;
3839
use syntax_expand::base::{NamedSyntaxExtension, ExtCtxt};
3940
use syntax::mut_visit::MutVisitor;
40-
use syntax::parse;
4141
use syntax::util::node_count::NodeCounter;
4242
use syntax::symbol::Symbol;
4343
use syntax_pos::FileName;
@@ -60,12 +60,11 @@ pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> {
6060
let krate = time(sess, "parsing", || {
6161
let _prof_timer = sess.prof.generic_activity("parse_crate");
6262

63-
match *input {
64-
Input::File(ref file) => parse::parse_crate_from_file(file, &sess.parse_sess),
65-
Input::Str {
66-
ref input,
67-
ref name,
68-
} => parse::parse_crate_from_source_str(name.clone(), input.clone(), &sess.parse_sess),
63+
match input {
64+
Input::File(file) => parse_crate_from_file(file, &sess.parse_sess),
65+
Input::Str { input, name } => {
66+
parse_crate_from_source_str(name.clone(), input.clone(), &sess.parse_sess)
67+
}
6968
}
7069
})?;
7170

@@ -484,7 +483,7 @@ pub fn lower_to_hir(
484483
) -> Result<hir::map::Forest> {
485484
// Lower AST to HIR.
486485
let hir_forest = time(sess, "lowering AST -> HIR", || {
487-
let nt_to_tokenstream = syntax::parse::nt_to_tokenstream;
486+
let nt_to_tokenstream = rustc_parse::nt_to_tokenstream;
488487
let hir_crate = lower_crate(sess, &dep_graph, &krate, resolver, nt_to_tokenstream);
489488

490489
if sess.opts.debugging_opts.hir_stats {

Diff for: src/librustc_interface/util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub fn diagnostics_registry() -> Registry {
5050
// FIXME: need to figure out a way to get these back in here
5151
// all_errors.extend_from_slice(get_codegen_backend(sess).diagnostics());
5252
all_errors.extend_from_slice(&rustc_metadata::error_codes::DIAGNOSTICS);
53+
all_errors.extend_from_slice(&rustc_parse::error_codes::DIAGNOSTICS);
5354
all_errors.extend_from_slice(&rustc_passes::error_codes::DIAGNOSTICS);
5455
all_errors.extend_from_slice(&rustc_plugin::error_codes::DIAGNOSTICS);
5556
all_errors.extend_from_slice(&rustc_mir::error_codes::DIAGNOSTICS);

Diff for: src/librustc_lexer/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Low-level Rust lexer.
22
//!
33
//! Tokens produced by this lexer are not yet ready for parsing the Rust syntax,
4-
//! for that see `libsyntax::parse::lexer`, which converts this basic token stream
4+
//! for that see `librustc_parse::lexer`, which converts this basic token stream
55
//! into wide tokens used by actual parser.
66
//!
77
//! The purpose of this crate is to convert raw sources into a labeled sequence

Diff for: src/librustc_metadata/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ rustc_serialize = { path = "../libserialize", package = "serialize" }
2323
stable_deref_trait = "1.0.0"
2424
syntax = { path = "../libsyntax" }
2525
syntax_expand = { path = "../libsyntax_expand" }
26+
rustc_parse = { path = "../librustc_parse" }
2627
syntax_pos = { path = "../libsyntax_pos" }

Diff for: src/librustc_metadata/rmeta/decoder/cstore_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use rustc::hir::map::{DefKey, DefPath, DefPathHash};
1818
use rustc::hir::map::definitions::DefPathTable;
1919
use rustc::util::nodemap::DefIdMap;
2020
use rustc_data_structures::svh::Svh;
21+
use rustc_parse::source_file_to_stream;
22+
use rustc_parse::parser::emit_unclosed_delims;
2123

2224
use smallvec::SmallVec;
2325
use std::any::Any;
@@ -27,8 +29,6 @@ use std::sync::Arc;
2729
use syntax::ast;
2830
use syntax::attr;
2931
use syntax::source_map;
30-
use syntax::parse::source_file_to_stream;
31-
use syntax::parse::parser::emit_unclosed_delims;
3232
use syntax::source_map::Spanned;
3333
use syntax::symbol::Symbol;
3434
use syntax_pos::{Span, FileName};

Diff for: src/librustc_parse/Cargo.toml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
authors = ["The Rust Project Developers"]
3+
name = "rustc_parse"
4+
version = "0.0.0"
5+
edition = "2018"
6+
7+
[lib]
8+
name = "rustc_parse"
9+
path = "lib.rs"
10+
doctest = false
11+
12+
[dependencies]
13+
bitflags = "1.0"
14+
log = "0.4"
15+
syntax_pos = { path = "../libsyntax_pos" }
16+
syntax = { path = "../libsyntax" }
17+
errors = { path = "../librustc_errors", package = "rustc_errors" }
18+
rustc_data_structures = { path = "../librustc_data_structures" }
19+
rustc_lexer = { path = "../librustc_lexer" }
20+
rustc_target = { path = "../librustc_target" }
21+
smallvec = { version = "1.0", features = ["union", "may_dangle"] }

0 commit comments

Comments
 (0)