From c54fc980f3e9f50620a8335029bf644753f7c89d Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Fri, 19 Dec 2014 00:46:26 +0200 Subject: [PATCH] Split resolve from rustc::middle into rustc_resolve. --- mk/crates.mk | 12 ++++-- mk/tests.mk | 3 +- src/librustc/lib.rs | 1 - src/librustc_driver/driver.rs | 7 ++-- src/librustc_driver/lib.rs | 1 + src/librustc_driver/test.rs | 2 +- .../resolve.rs => librustc_resolve/lib.rs} | 38 +++++++++++++------ src/test/run-pass/issue-14254.rs | 16 ++++---- 8 files changed, 51 insertions(+), 29 deletions(-) rename src/{librustc/middle/resolve.rs => librustc_resolve/lib.rs} (99%) diff --git a/mk/crates.mk b/mk/crates.mk index fafe77c78da..e20cb06e3a8 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -53,7 +53,8 @@ TARGET_CRATES := libc std flate arena term \ serialize getopts collections test time rand \ log regex graphviz core rbml alloc \ unicode -RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_driver rustc_trans rustc_back rustc_llvm +RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \ + rustc_trans rustc_back rustc_llvm HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc regex_macros fmt_macros CRATES := $(TARGET_CRATES) $(HOST_CRATES) TOOLS := compiletest rustdoc rustc @@ -67,11 +68,12 @@ DEPS_std := core libc rand alloc collections unicode \ DEPS_graphviz := std DEPS_syntax := std term serialize log fmt_macros arena libc DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \ - rustc_typeck log syntax serialize rustc_llvm rustc_trans + rustc_typeck rustc_resolve log syntax serialize rustc_llvm rustc_trans DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \ log syntax serialize rustc_llvm DEPS_rustc_typeck := rustc syntax DEPS_rustc_borrowck := rustc log graphviz syntax +DEPS_rustc_resolve := rustc log syntax DEPS_rustc := syntax flate arena serialize getopts rbml \ time log graphviz rustc_llvm rustc_back DEPS_rustc_llvm := native:rustllvm libc std @@ -118,9 +120,11 @@ DOC_CRATES := $(filter-out rustc, \ $(filter-out rustc_trans, \ $(filter-out rustc_typeck, \ $(filter-out rustc_borrowck, \ + $(filter-out rustc_resolve, \ $(filter-out rustc_driver, \ - $(filter-out syntax, $(CRATES))))))) -COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck rustc_typeck rustc_driver syntax + $(filter-out syntax, $(CRATES)))))))) +COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck rustc_resolve \ + rustc_typeck rustc_driver syntax # This macro creates some simple definitions for each crate being built, just # some munging of all of the parameters above. diff --git a/mk/tests.mk b/mk/tests.mk index 3340f9b4969..a5495a44a11 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -21,7 +21,8 @@ $(eval $(call RUST_CRATE,coretest)) TEST_TARGET_CRATES = $(filter-out core unicode,$(TARGET_CRATES)) coretest TEST_DOC_CRATES = $(DOC_CRATES) -TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_trans,$(HOST_CRATES)) +TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve rustc_trans,\ + $(HOST_CRATES)) TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES) ###################################################################### diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 90e9973c3f3..669a5144970 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -90,7 +90,6 @@ pub mod middle { pub mod reachable; pub mod region; pub mod recursion_limit; - pub mod resolve; pub mod resolve_lifetime; pub mod stability; pub mod subst; diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 787b869a18f..60b890b0370 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -20,6 +20,7 @@ use rustc::plugin::registry::Registry; use rustc::plugin; use rustc::util::common::time; use rustc_borrowck as borrowck; +use rustc_resolve as resolve; use rustc_trans::back::link; use rustc_trans::back::write; use rustc_trans::save; @@ -341,7 +342,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, let lang_items = time(time_passes, "language item collection", (), |_| middle::lang_items::collect_language_items(krate, &sess)); - let middle::resolve::CrateMap { + let resolve::CrateMap { def_map, freevars, capture_mode_map, @@ -350,8 +351,8 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, external_exports, last_private_map } = - time(time_passes, "resolution", (), |_| - middle::resolve::resolve_crate(&sess, &lang_items, krate)); + time(time_passes, "resolution", (), + |_| resolve::resolve_crate(&sess, &lang_items, krate)); // Discard MTWT tables that aren't required past resolution. syntax::ext::mtwt::clear_tables(); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 120654678e9..34d9fd6bcad 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -35,6 +35,7 @@ extern crate libc; extern crate rustc; extern crate rustc_back; extern crate rustc_borrowck; +extern crate rustc_resolve; extern crate rustc_trans; extern crate rustc_typeck; #[phase(plugin, link)] extern crate log; diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index b2c661cc58a..090d6a7a3ca 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -13,9 +13,9 @@ use diagnostic; use diagnostic::Emitter; use driver; +use rustc_resolve as resolve; use rustc_typeck::middle::lang_items; use rustc_typeck::middle::region::{mod, CodeExtent}; -use rustc_typeck::middle::resolve; use rustc_typeck::middle::resolve_lifetime; use rustc_typeck::middle::stability; use rustc_typeck::middle::subst; diff --git a/src/librustc/middle/resolve.rs b/src/librustc_resolve/lib.rs similarity index 99% rename from src/librustc/middle/resolve.rs rename to src/librustc_resolve/lib.rs index 323ea26879b..b462bfe41b9 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc_resolve/lib.rs @@ -8,6 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![crate_name = "rustc_resolve"] +#![experimental] +#![crate_type = "dylib"] +#![crate_type = "rlib"] +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/nightly/")] + +#![feature(globs, phase, slicing_syntax)] +#![feature(rustc_diagnostic_macros)] + +#[phase(plugin, link)] extern crate log; +#[phase(plugin, link)] extern crate syntax; + +extern crate rustc; + use self::PatternBindingMode::*; use self::Namespace::*; use self::NamespaceError::*; @@ -30,17 +46,17 @@ use self::ModuleKind::*; use self::TraitReferenceType::*; use self::FallbackChecks::*; -use session::Session; -use lint; -use metadata::csearch; -use metadata::decoder::{DefLike, DlDef, DlField, DlImpl}; -use middle::def::*; -use middle::lang_items::LanguageItems; -use middle::pat_util::pat_bindings; -use middle::privacy::*; -use middle::subst::{ParamSpace, FnSpace, TypeSpace}; -use middle::ty::{CaptureModeMap, Freevar, FreevarMap, TraitMap}; -use util::nodemap::{NodeMap, NodeSet, DefIdSet, FnvHashMap}; +use rustc::session::Session; +use rustc::lint; +use rustc::metadata::csearch; +use rustc::metadata::decoder::{DefLike, DlDef, DlField, DlImpl}; +use rustc::middle::def::*; +use rustc::middle::lang_items::LanguageItems; +use rustc::middle::pat_util::pat_bindings; +use rustc::middle::privacy::*; +use rustc::middle::subst::{ParamSpace, FnSpace, TypeSpace}; +use rustc::middle::ty::{CaptureModeMap, Freevar, FreevarMap, TraitMap}; +use rustc::util::nodemap::{NodeMap, NodeSet, DefIdSet, FnvHashMap}; use syntax::ast::{Arm, BindByRef, BindByValue, BindingMode, Block, Crate, CrateNum}; use syntax::ast::{DeclItem, DefId, Expr, ExprAgain, ExprBreak, ExprField}; diff --git a/src/test/run-pass/issue-14254.rs b/src/test/run-pass/issue-14254.rs index 160828d42fc..ad4ed03e6e2 100644 --- a/src/test/run-pass/issue-14254.rs +++ b/src/test/run-pass/issue-14254.rs @@ -24,7 +24,7 @@ impl BarTy { fn b(&self) {} } -// If these fail, it's necessary to update middle::resolve and the cfail tests. +// If these fail, it's necessary to update rustc_resolve and the cfail tests. impl Foo for *const BarTy { fn bar(&self) { self.baz(); @@ -33,7 +33,7 @@ impl Foo for *const BarTy { } } -// If these fail, it's necessary to update middle::resolve and the cfail tests. +// If these fail, it's necessary to update rustc_resolve and the cfail tests. impl<'a> Foo for &'a BarTy { fn bar(&self) { self.baz(); @@ -45,7 +45,7 @@ impl<'a> Foo for &'a BarTy { } } -// If these fail, it's necessary to update middle::resolve and the cfail tests. +// If these fail, it's necessary to update rustc_resolve and the cfail tests. impl<'a> Foo for &'a mut BarTy { fn bar(&self) { self.baz(); @@ -57,7 +57,7 @@ impl<'a> Foo for &'a mut BarTy { } } -// If these fail, it's necessary to update middle::resolve and the cfail tests. +// If these fail, it's necessary to update rustc_resolve and the cfail tests. impl Foo for Box { fn bar(&self) { self.baz(); @@ -65,7 +65,7 @@ impl Foo for Box { } } -// If these fail, it's necessary to update middle::resolve and the cfail tests. +// If these fail, it's necessary to update rustc_resolve and the cfail tests. impl Foo for *const int { fn bar(&self) { self.baz(); @@ -73,7 +73,7 @@ impl Foo for *const int { } } -// If these fail, it's necessary to update middle::resolve and the cfail tests. +// If these fail, it's necessary to update rustc_resolve and the cfail tests. impl<'a> Foo for &'a int { fn bar(&self) { self.baz(); @@ -81,7 +81,7 @@ impl<'a> Foo for &'a int { } } -// If these fail, it's necessary to update middle::resolve and the cfail tests. +// If these fail, it's necessary to update rustc_resolve and the cfail tests. impl<'a> Foo for &'a mut int { fn bar(&self) { self.baz(); @@ -89,7 +89,7 @@ impl<'a> Foo for &'a mut int { } } -// If these fail, it's necessary to update middle::resolve and the cfail tests. +// If these fail, it's necessary to update rustc_resolve and the cfail tests. impl Foo for Box { fn bar(&self) { self.baz();