Skip to content

move librustc/front to libsyntax #17160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use back::link;
use back::write;
use driver::session::Session;
use driver::config;
use front;
use lint;
use llvm::{ContextRef, ModuleRef};
use metadata::common::LinkMeta;
Expand Down Expand Up @@ -166,7 +165,7 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
}

if sess.show_span() {
front::show_span::run(sess, &krate);
syntax::show_span::run(sess.diagnostic(), &krate);
}

krate
Expand Down Expand Up @@ -194,11 +193,29 @@ pub fn phase_2_configure_and_expand(sess: &Session,
*sess.crate_metadata.borrow_mut() =
collect_crate_metadata(sess, krate.attrs.as_slice());

time(time_passes, "gated feature checking", (), |_|
front::feature_gate::check_crate(sess, &krate));
time(time_passes, "gated feature checking", (), |_| {
let (features, unknown_features) =
syntax::feature_gate::check_crate(&sess.parse_sess.span_diagnostic, &krate);

for uf in unknown_features.iter() {
sess.add_lint(lint::builtin::UNKNOWN_FEATURES,
ast::CRATE_NODE_ID,
*uf,
"unknown feature".to_string());
}

sess.abort_if_errors();
*sess.features.borrow_mut() = features;
});

let any_exe = sess.crate_types.borrow().iter().any(|ty| {
*ty == config::CrateTypeExecutable
});

krate = time(time_passes, "crate injection", krate, |krate|
front::std_inject::maybe_inject_crates_ref(sess, krate));
syntax::std_inject::maybe_inject_crates_ref(krate,
sess.opts.alt_std_name.clone(),
any_exe));

// strip before expansion to allow macros to depend on
// configuration variables e.g/ in
Expand All @@ -209,7 +226,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
// baz! should not use this definition unless foo is enabled.

krate = time(time_passes, "configuration 1", krate, |krate|
front::config::strip_unconfigured_items(krate));
syntax::config::strip_unconfigured_items(krate));

let mut addl_plugins = Some(addl_plugins);
let Plugins { macros, registrars }
Expand All @@ -219,7 +236,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
let mut registry = Registry::new(&krate);

time(time_passes, "plugin registration", (), |_| {
if sess.features.rustc_diagnostic_macros.get() {
if sess.features.borrow().rustc_diagnostic_macros {
registry.register_macro("__diagnostic_used",
diagnostics::plugin::expand_diagnostic_used);
registry.register_macro("__register_diagnostic",
Expand Down Expand Up @@ -271,7 +288,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap());
}
let cfg = syntax::ext::expand::ExpansionConfig {
deriving_hash_type_parameter: sess.features.default_type_params.get(),
deriving_hash_type_parameter: sess.features.borrow().default_type_params,
crate_name: crate_name.to_string(),
};
let ret = syntax::ext::expand::expand_crate(&sess.parse_sess,
Expand All @@ -290,13 +307,16 @@ pub fn phase_2_configure_and_expand(sess: &Session,

// strip again, in case expansion added anything with a #[cfg].
krate = time(time_passes, "configuration 2", krate, |krate|
front::config::strip_unconfigured_items(krate));
syntax::config::strip_unconfigured_items(krate));

krate = time(time_passes, "maybe building test harness", krate, |krate|
front::test::modify_for_testing(sess, krate));
syntax::test::modify_for_testing(&sess.parse_sess,
&sess.opts.cfg,
krate,
sess.diagnostic()));

krate = time(time_passes, "prelude injection", krate, |krate|
front::std_inject::maybe_inject_prelude(sess, krate));
syntax::std_inject::maybe_inject_prelude(krate));

time(time_passes, "checking that all macro invocations are gone", &krate, |krate|
syntax::ext::expand::check_for_macros(&sess.parse_sess, krate));
Expand Down
19 changes: 5 additions & 14 deletions src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use driver::config;
use driver::driver;
use front;
use metadata::cstore::CStore;
use metadata::filesearch;
use lint;
Expand All @@ -21,6 +20,7 @@ use syntax::ast::NodeId;
use syntax::codemap::Span;
use syntax::diagnostic;
use syntax::diagnostics;
use syntax::feature_gate;
use syntax::parse;
use syntax::parse::token;
use syntax::parse::ParseSess;
Expand All @@ -47,10 +47,9 @@ pub struct Session {
pub working_dir: Path,
pub lint_store: RefCell<lint::LintStore>,
pub lints: RefCell<NodeMap<Vec<(lint::LintId, codemap::Span, String)>>>,
pub node_id: Cell<ast::NodeId>,
pub crate_types: RefCell<Vec<config::CrateType>>,
pub crate_metadata: RefCell<Vec<String>>,
pub features: front::feature_gate::Features,
pub features: RefCell<feature_gate::Features>,

/// The maximum recursion limit for potentially infinitely recursive
/// operations such as auto-dereference and monomorphization.
Expand Down Expand Up @@ -129,17 +128,10 @@ impl Session {
lints.insert(id, vec!((lint_id, sp, msg)));
}
pub fn next_node_id(&self) -> ast::NodeId {
self.reserve_node_ids(1)
self.parse_sess.next_node_id()
}
pub fn reserve_node_ids(&self, count: ast::NodeId) -> ast::NodeId {
let v = self.node_id.get();

match v.checked_add(&count) {
Some(next) => { self.node_id.set(next); }
None => self.bug("Input too large, ran out of node ids!")
}

v
self.parse_sess.reserve_node_ids(count)
}
pub fn diagnostic<'a>(&'a self) -> &'a diagnostic::SpanHandler {
&self.parse_sess.span_diagnostic
Expand Down Expand Up @@ -251,10 +243,9 @@ pub fn build_session_(sopts: config::Options,
working_dir: os::getcwd(),
lint_store: RefCell::new(lint::LintStore::new()),
lints: RefCell::new(NodeMap::new()),
node_id: Cell::new(1),
crate_types: RefCell::new(Vec::new()),
crate_metadata: RefCell::new(Vec::new()),
features: front::feature_gate::Features::new(),
features: RefCell::new(feature_gate::Features::new()),
recursion_limit: Cell::new(64),
};

Expand Down
8 changes: 0 additions & 8 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ pub mod middle {
pub mod weak_lang_items;
}

pub mod front {
pub mod config;
pub mod test;
pub mod std_inject;
pub mod feature_gate;
pub mod show_span;
}

pub mod metadata;

pub mod driver;
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2811,7 +2811,7 @@ impl<'a> Resolver<'a> {
import_span: Span,
name: Name,
namespace: Namespace) {
if self.session.features.import_shadowing.get() {
if self.session.features.borrow().import_shadowing {
return
}

Expand All @@ -2837,7 +2837,7 @@ impl<'a> Resolver<'a> {
&mut ImportResolution,
import_span: Span,
name: Name) {
if self.session.features.import_shadowing.get() {
if self.session.features.borrow().import_shadowing {
return
}

Expand Down Expand Up @@ -2919,7 +2919,7 @@ impl<'a> Resolver<'a> {
module: &Module,
name: Name,
span: Span) {
if self.session.features.import_shadowing.get() {
if self.session.features.borrow().import_shadowing {
return
}

Expand All @@ -2937,7 +2937,7 @@ impl<'a> Resolver<'a> {
module: &Module,
name: Name,
span: Span) {
if self.session.features.import_shadowing.get() {
if self.session.features.borrow().import_shadowing {
return
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ fn ast_path_substs<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
}

if supplied_ty_param_count > required_ty_param_count
&& !this.tcx().sess.features.default_type_params.get() {
&& !this.tcx().sess.features.borrow().default_type_params {
span_err!(this.tcx().sess, path.span, E0108,
"default type parameters are experimental and possibly buggy");
span_note!(this.tcx().sess, path.span,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ fn try_overloaded_call(fcx: &FnCtxt,
fcx.inh.method_map.borrow_mut().insert(method_call, method_callee);
write_call(fcx, call_expression, output_type);

if !fcx.tcx().sess.features.overloaded_calls.get() {
if !fcx.tcx().sess.features.borrow().overloaded_calls {
span_err!(fcx.tcx().sess, call_expression.span, E0056,
"overloaded calls are experimental");
span_note!(fcx.tcx().sess, call_expression.span,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/front/config.rs → src/libsyntax/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use syntax::fold::Folder;
use syntax::{ast, fold, attr};
use syntax::codemap::Spanned;
use syntax::ptr::P;
use fold::Folder;
use {ast, fold, attr};
use codemap::Spanned;
use ptr::P;

/// A folder that strips out items that do not belong in the current
/// configuration.
Expand Down
Loading