From 2854d1bfc23f9851f86600863f1ca191ebe45698 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 5 Dec 2014 14:17:35 -0500 Subject: [PATCH] Separate borrowck into its own crate and remove dead code as well. --- mk/crates.mk | 10 ++-- mk/tests.mk | 2 +- src/librustc/lib.rs | 1 - .../borrowck/check_loans.rs | 24 ++++---- .../borrowck/doc.rs | 0 .../borrowck/fragments.rs | 19 +++---- .../borrowck/gather_loans/gather_moves.rs | 21 ++++--- .../borrowck/gather_loans/lifetime.rs | 12 ++-- .../borrowck/gather_loans/mod.rs | 20 +++---- .../borrowck/gather_loans/move_error.rs | 9 ++- .../borrowck/gather_loans/restrictions.rs | 14 ++--- .../borrowck/mod.rs | 35 ++++-------- .../borrowck/move_data.rs | 55 ++++--------------- .../graphviz.rs | 18 +++--- src/librustc_borrowck/lib.rs | 39 +++++++++++++ src/librustc_driver/driver.rs | 3 +- src/librustc_driver/lib.rs | 3 +- src/librustc_driver/pretty.rs | 6 +- 18 files changed, 139 insertions(+), 152 deletions(-) rename src/{librustc/middle => librustc_borrowck}/borrowck/check_loans.rs (98%) rename src/{librustc/middle => librustc_borrowck}/borrowck/doc.rs (100%) rename src/{librustc/middle => librustc_borrowck}/borrowck/fragments.rs (97%) rename src/{librustc/middle => librustc_borrowck}/borrowck/gather_loans/gather_moves.rs (95%) rename src/{librustc/middle => librustc_borrowck}/borrowck/gather_loans/lifetime.rs (96%) rename src/{librustc/middle => librustc_borrowck}/borrowck/gather_loans/mod.rs (98%) rename src/{librustc/middle => librustc_borrowck}/borrowck/gather_loans/move_error.rs (97%) rename src/{librustc/middle => librustc_borrowck}/borrowck/gather_loans/restrictions.rs (96%) rename src/{librustc/middle => librustc_borrowck}/borrowck/mod.rs (97%) rename src/{librustc/middle => librustc_borrowck}/borrowck/move_data.rs (94%) rename src/{librustc/middle/borrowck => librustc_borrowck}/graphviz.rs (93%) create mode 100644 src/librustc_borrowck/lib.rs diff --git a/mk/crates.mk b/mk/crates.mk index 3a2def389cc..a47d4871326 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -53,7 +53,7 @@ TARGET_CRATES := libc std flate arena term \ serialize getopts collections test time rand \ log regex graphviz core rbml alloc rustrt \ unicode -RUSTC_CRATES := rustc rustc_typeck rustc_driver rustc_trans rustc_back rustc_llvm +RUSTC_CRATES := rustc rustc_typeck rustc_borrowck 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 +67,12 @@ DEPS_std := core libc rand alloc collections rustrt unicode \ native:rust_builtin native:backtrace DEPS_graphviz := std DEPS_syntax := std term serialize log fmt_macros arena libc -DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back \ +DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \ rustc_typeck 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 := syntax flate arena serialize getopts rbml \ time log graphviz rustc_llvm rustc_back DEPS_rustc_llvm := native:rustllvm libc std @@ -117,9 +118,10 @@ ONLY_RLIB_unicode := 1 DOC_CRATES := $(filter-out rustc, \ $(filter-out rustc_trans, \ $(filter-out rustc_typeck, \ + $(filter-out rustc_borrowck, \ $(filter-out rustc_driver, \ - $(filter-out syntax, $(CRATES)))))) -COMPILER_DOC_CRATES := rustc rustc_trans rustc_typeck rustc_driver syntax + $(filter-out syntax, $(CRATES))))))) +COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck 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 b4b8249a8cb..3340f9b4969 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -21,7 +21,7 @@ $(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_trans,$(HOST_CRATES)) +TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck 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 918f612aaa5..51cb7e193ff 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -61,7 +61,6 @@ pub mod back { pub mod middle { pub mod astconv_util; pub mod astencode; - pub mod borrowck; pub mod cfg; pub mod check_const; pub mod check_static_recursion; diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs similarity index 98% rename from src/librustc/middle/borrowck/check_loans.rs rename to src/librustc_borrowck/borrowck/check_loans.rs index 5f030324d42..4244cec7534 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -18,18 +18,16 @@ // 4. moves do not affect things loaned out in any way use self::UseError::*; -use middle::borrowck::*; -use middle::borrowck::LoanPathElem::*; -use middle::borrowck::LoanPathKind::*; -use middle::expr_use_visitor as euv; -use middle::mem_categorization as mc; -use middle::region; -use middle::ty::ParameterEnvironment; -use middle::ty; -use syntax::ast::NodeId; +use borrowck::*; +use borrowck::LoanPathElem::*; +use borrowck::LoanPathKind::*; +use rustc::middle::expr_use_visitor as euv; +use rustc::middle::mem_categorization as mc; +use rustc::middle::region; +use rustc::middle::ty; +use rustc::util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; -use util::ppaux::Repr; use std::rc::Rc; @@ -91,7 +89,7 @@ struct CheckLoanCtxt<'a, 'tcx: 'a> { dfcx_loans: &'a LoanDataFlow<'a, 'tcx>, move_data: move_data::FlowedMoveData<'a, 'tcx>, all_loans: &'a [Loan<'tcx>], - param_env: &'a ParameterEnvironment<'tcx>, + param_env: &'a ty::ParameterEnvironment<'tcx>, } impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { @@ -196,12 +194,12 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, dfcx_loans: &LoanDataFlow<'b, 'tcx>, move_data: move_data::FlowedMoveData<'c, 'tcx>, all_loans: &[Loan<'tcx>], - fn_id: NodeId, + fn_id: ast::NodeId, decl: &ast::FnDecl, body: &ast::Block) { debug!("check_loans(body id={})", body.id); - let param_env = ParameterEnvironment::for_item(bccx.tcx, fn_id); + let param_env = ty::ParameterEnvironment::for_item(bccx.tcx, fn_id); let mut clcx = CheckLoanCtxt { bccx: bccx, diff --git a/src/librustc/middle/borrowck/doc.rs b/src/librustc_borrowck/borrowck/doc.rs similarity index 100% rename from src/librustc/middle/borrowck/doc.rs rename to src/librustc_borrowck/borrowck/doc.rs diff --git a/src/librustc/middle/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs similarity index 97% rename from src/librustc/middle/borrowck/fragments.rs rename to src/librustc_borrowck/borrowck/fragments.rs index 056d4f9d732..25ed5182555 100644 --- a/src/librustc/middle/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -14,16 +14,15 @@ use self::Fragment::*; -use session::config; -use middle::borrowck::{LoanPath}; -use middle::borrowck::LoanPathKind::{LpVar, LpUpvar, LpDowncast, LpExtend}; -use middle::borrowck::LoanPathElem::{LpDeref, LpInterior}; -use middle::borrowck::move_data::{InvalidMovePathIndex}; -use middle::borrowck::move_data::{MoveData, MovePathIndex}; -use middle::ty; -use middle::mem_categorization as mc; -use util::ppaux::{Repr, UserString}; - +use borrowck::{LoanPath}; +use borrowck::LoanPathKind::{LpVar, LpUpvar, LpDowncast, LpExtend}; +use borrowck::LoanPathElem::{LpDeref, LpInterior}; +use borrowck::move_data::{InvalidMovePathIndex}; +use borrowck::move_data::{MoveData, MovePathIndex}; +use rustc::session::config; +use rustc::middle::ty; +use rustc::middle::mem_categorization as mc; +use rustc::util::ppaux::{Repr, UserString}; use std::mem; use std::rc::Rc; use std::slice; diff --git a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs similarity index 95% rename from src/librustc/middle/borrowck/gather_loans/gather_moves.rs rename to src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index 65114160504..01cbab6dbf4 100644 --- a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -10,19 +10,18 @@ //! Computes moves. -use middle::borrowck::*; -use middle::borrowck::LoanPathKind::*; -use middle::borrowck::gather_loans::move_error::MoveSpanAndPath; -use middle::borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector}; -use middle::borrowck::move_data::*; -use middle::expr_use_visitor as euv; -use middle::mem_categorization as mc; -use middle::ty; +use borrowck::*; +use borrowck::LoanPathKind::*; +use borrowck::gather_loans::move_error::MoveSpanAndPath; +use borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector}; +use borrowck::move_data::*; +use rustc::middle::expr_use_visitor as euv; +use rustc::middle::mem_categorization as mc; +use rustc::middle::ty; +use rustc::util::ppaux::Repr; +use std::rc::Rc; use syntax::ast; use syntax::codemap::Span; -use util::ppaux::Repr; - -use std::rc::Rc; struct GatherMoveInfo<'tcx> { id: ast::NodeId, diff --git a/src/librustc/middle/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs similarity index 96% rename from src/librustc/middle/borrowck/gather_loans/lifetime.rs rename to src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index e6a7c150df8..d7c96346463 100644 --- a/src/librustc/middle/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -11,12 +11,12 @@ //! This module implements the check that the lifetime of a borrow //! does not exceed the lifetime of the value being borrowed. -use middle::borrowck::*; -use middle::expr_use_visitor as euv; -use middle::mem_categorization as mc; -use middle::region; -use middle::ty; -use util::ppaux::Repr; +use borrowck::*; +use rustc::middle::expr_use_visitor as euv; +use rustc::middle::mem_categorization as mc; +use rustc::middle::region; +use rustc::middle::ty; +use rustc::util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs similarity index 98% rename from src/librustc/middle/borrowck/gather_loans/mod.rs rename to src/librustc_borrowck/borrowck/gather_loans/mod.rs index ca9d4b512b3..08d12f8282b 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -16,16 +16,14 @@ // their associated scopes. In phase two, checking loans, we will then make // sure that all of these loans are honored. -use middle::borrowck::*; -use middle::borrowck::LoanPathKind::*; -use middle::borrowck::move_data::MoveData; -use middle::expr_use_visitor as euv; -use middle::mem_categorization as mc; -use middle::region; -use middle::ty::ParameterEnvironment; -use middle::ty; -use util::ppaux::{Repr}; - +use borrowck::*; +use borrowck::LoanPathKind::*; +use borrowck::move_data::MoveData; +use rustc::middle::expr_use_visitor as euv; +use rustc::middle::mem_categorization as mc; +use rustc::middle::region; +use rustc::middle::ty; +use rustc::util::ppaux::{Repr}; use syntax::ast; use syntax::codemap::Span; use syntax::visit; @@ -51,7 +49,7 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, move_error_collector: move_error::MoveErrorCollector::new(), }; - let param_env = ParameterEnvironment::for_item(bccx.tcx, fn_id); + let param_env = ty::ParameterEnvironment::for_item(bccx.tcx, fn_id); { let mut euv = euv::ExprUseVisitor::new(&mut glcx, diff --git a/src/librustc/middle/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs similarity index 97% rename from src/librustc/middle/borrowck/gather_loans/move_error.rs rename to src/librustc_borrowck/borrowck/gather_loans/move_error.rs index aaa0fa88242..fbe78152a60 100644 --- a/src/librustc/middle/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -8,15 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::mem_categorization as mc; -use middle::borrowck::BorrowckCtxt; -use middle::ty; - +use borrowck::BorrowckCtxt; +use rustc::middle::mem_categorization as mc; +use rustc::middle::ty; +use rustc::util::ppaux::UserString; use std::cell::RefCell; use syntax::ast; use syntax::codemap; use syntax::print::pprust; -use util::ppaux::UserString; pub struct MoveErrorCollector<'tcx> { errors: RefCell>> diff --git a/src/librustc/middle/borrowck/gather_loans/restrictions.rs b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs similarity index 96% rename from src/librustc/middle/borrowck/gather_loans/restrictions.rs rename to src/librustc_borrowck/borrowck/gather_loans/restrictions.rs index bd9cf8f84b6..c783489dab7 100644 --- a/src/librustc/middle/borrowck/gather_loans/restrictions.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs @@ -12,14 +12,14 @@ pub use self::RestrictionResult::*; -use middle::borrowck::*; -use middle::borrowck::LoanPathElem::*; -use middle::borrowck::LoanPathKind::*; -use middle::expr_use_visitor as euv; -use middle::mem_categorization as mc; -use middle::ty; +use borrowck::*; +use borrowck::LoanPathElem::*; +use borrowck::LoanPathKind::*; +use rustc::middle::expr_use_visitor as euv; +use rustc::middle::mem_categorization as mc; +use rustc::middle::ty; +use rustc::util::ppaux::Repr; use syntax::codemap::Span; -use util::ppaux::Repr; use std::rc::Rc; diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs similarity index 97% rename from src/librustc/middle/borrowck/mod.rs rename to src/librustc_borrowck/borrowck/mod.rs index e90de1b6912..1722f9a1f75 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -18,16 +18,15 @@ pub use self::bckerr_code::*; pub use self::AliasableViolationKind::*; pub use self::MovedValueUseKind::*; -use middle::cfg; -use middle::dataflow::DataFlowContext; -use middle::dataflow::BitwiseOperator; -use middle::dataflow::DataFlowOperator; -use middle::expr_use_visitor as euv; -use middle::mem_categorization as mc; -use middle::region; -use middle::ty::{mod, ParameterEnvironment, Ty}; -use util::ppaux::{note_and_explain_region, Repr, UserString}; - +use rustc::middle::cfg; +use rustc::middle::dataflow::DataFlowContext; +use rustc::middle::dataflow::BitwiseOperator; +use rustc::middle::dataflow::DataFlowOperator; +use rustc::middle::expr_use_visitor as euv; +use rustc::middle::mem_categorization as mc; +use rustc::middle::region; +use rustc::middle::ty::{mod, Ty}; +use rustc::util::ppaux::{note_and_explain_region, Repr, UserString}; use std::rc::Rc; use std::string::String; use syntax::ast; @@ -55,8 +54,6 @@ pub mod check_loans; pub mod gather_loans; -pub mod graphviz; - pub mod move_data; #[deriving(Clone)] @@ -298,18 +295,6 @@ pub struct LoanPath<'tcx> { ty: ty::Ty<'tcx>, } -impl<'tcx> LoanPath<'tcx> { - pub fn eq_debug(&self, that: &LoanPath<'tcx>, tcx: &ty::ctxt<'tcx>) -> bool { - let r = self.kind == that.kind; - if r && self.ty != that.ty { - panic!("eq variants ineq types: {} == {}, {} != {}", - self.repr(tcx), that.repr(tcx), - self.ty.repr(tcx), that.ty.repr(tcx)); - } - r - } -} - impl<'tcx> PartialEq for LoanPath<'tcx> { fn eq(&self, that: &LoanPath<'tcx>) -> bool { let r = self.kind == that.kind; @@ -560,7 +545,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { lp: &LoanPath<'tcx>, the_move: &move_data::Move, moved_lp: &LoanPath<'tcx>, - param_env: &ParameterEnvironment<'tcx>) { + param_env: &ty::ParameterEnvironment<'tcx>) { let verb = match use_kind { MovedInUse => "use", MovedInCapture => "capture", diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs similarity index 94% rename from src/librustc/middle/borrowck/move_data.rs rename to src/librustc_borrowck/borrowck/move_data.rs index 3bb6145c5ca..681a5772849 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -13,24 +13,24 @@ pub use self::MoveKind::*; +use borrowck::*; +use borrowck::LoanPathKind::{LpVar, LpUpvar, LpDowncast, LpExtend}; +use borrowck::LoanPathElem::{LpInterior}; +use rustc::middle::cfg; +use rustc::middle::dataflow::DataFlowContext; +use rustc::middle::dataflow::BitwiseOperator; +use rustc::middle::dataflow::DataFlowOperator; +use rustc::middle::expr_use_visitor as euv; +use rustc::middle::mem_categorization as mc; +use rustc::middle::ty; +use rustc::util::nodemap::{FnvHashMap, NodeSet}; +use rustc::util::ppaux::Repr; use std::cell::RefCell; use std::rc::Rc; use std::uint; -use middle::borrowck::*; -use middle::borrowck::LoanPathKind::{LpVar, LpUpvar, LpDowncast, LpExtend}; -use middle::borrowck::LoanPathElem::{LpInterior}; -use middle::cfg; -use middle::dataflow::DataFlowContext; -use middle::dataflow::BitwiseOperator; -use middle::dataflow::DataFlowOperator; -use middle::expr_use_visitor as euv; -use middle::mem_categorization as mc; -use middle::ty; use syntax::ast; use syntax::ast_util; use syntax::codemap::Span; -use util::nodemap::{FnvHashMap, NodeSet}; -use util::ppaux::Repr; #[path="fragments.rs"] pub mod fragments; @@ -220,37 +220,6 @@ fn loan_path_is_precise(loan_path: &LoanPath) -> bool { } } -impl Move { - pub fn to_string<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) -> String { - format!("Move{} path: {}, id: {}, kind: {} {}", - "{", - move_data.path_loan_path(self.path).repr(tcx), - self.id, - self.kind, - "}") - } -} - -impl Assignment { - pub fn to_string<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) -> String { - format!("Assignment{} path: {}, id: {} {}", - "{", - move_data.path_loan_path(self.path).repr(tcx), - self.id, - "}") - } -} - -impl VariantMatch { - pub fn to_string<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) -> String { - format!("VariantMatch{} path: {}, id: {} {}", - "{", - move_data.path_loan_path(self.path).repr(tcx), - self.id, - "}") - } -} - impl<'tcx> MoveData<'tcx> { pub fn new() -> MoveData<'tcx> { MoveData { diff --git a/src/librustc/middle/borrowck/graphviz.rs b/src/librustc_borrowck/graphviz.rs similarity index 93% rename from src/librustc/middle/borrowck/graphviz.rs rename to src/librustc_borrowck/graphviz.rs index 32fa5f8c3a9..36c74720be4 100644 --- a/src/librustc/middle/borrowck/graphviz.rs +++ b/src/librustc_borrowck/graphviz.rs @@ -14,17 +14,15 @@ pub use self::Variant::*; -/// For clarity, rename the graphviz crate locally to dot. -use graphviz as dot; -pub use middle::cfg::graphviz::{Node, Edge}; -use middle::cfg::graphviz as cfg_dot; - -use middle::borrowck; -use middle::borrowck::{BorrowckCtxt, LoanPath}; -use middle::cfg::{CFGIndex}; -use middle::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit}; -use middle::dataflow; +pub use rustc::middle::cfg::graphviz::{Node, Edge}; +use rustc::middle::cfg::graphviz as cfg_dot; +use borrowck; +use borrowck::{BorrowckCtxt, LoanPath}; +use dot; +use rustc::middle::cfg::{CFGIndex}; +use rustc::middle::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit}; +use rustc::middle::dataflow; use std::rc::Rc; #[deriving(Show)] diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs new file mode 100644 index 00000000000..f187c0c1530 --- /dev/null +++ b/src/librustc_borrowck/lib.rs @@ -0,0 +1,39 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "rustc_borrowck"] +#![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(default_type_params, globs, if_let, import_shadowing, macro_rules, phase, quote)] +#![feature(slicing_syntax, tuple_indexing, unsafe_destructor)] +#![feature(rustc_diagnostic_macros)] +#![allow(non_camel_case_types)] + +#[phase(plugin, link)] extern crate log; +#[phase(plugin, link)] extern crate syntax; + +// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck` +// refers to the borrowck-specific graphviz adapter traits. +extern crate "graphviz" as dot; +extern crate rustc; + +pub use borrowck::check_crate; +pub use borrowck::build_borrowck_dataflow_data_for_fn; +pub use borrowck::FnPartsWithCFG; + +mod borrowck; + +pub mod graphviz; + diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 749bed15e38..6cddcaca1e4 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -19,6 +19,7 @@ use rustc::plugin::load::Plugins; use rustc::plugin::registry::Registry; use rustc::plugin; use rustc::util::common::time; +use rustc_borrowck as borrowck; use rustc_trans::back::link; use rustc_trans::back::write; use rustc_trans::save; @@ -420,7 +421,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, middle::liveness::check_crate(&ty_cx)); time(time_passes, "borrow checking", (), |_| - middle::borrowck::check_crate(&ty_cx)); + borrowck::check_crate(&ty_cx)); time(time_passes, "rvalue checking", (), |_| middle::check_rvalues::check_crate(&ty_cx, krate)); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index f6b808e8e1b..85d9646c282 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -32,9 +32,10 @@ extern crate getopts; extern crate graphviz; extern crate libc; extern crate rustc; -extern crate rustc_typeck; extern crate rustc_back; +extern crate rustc_borrowck; extern crate rustc_trans; +extern crate rustc_typeck; #[phase(plugin, link)] extern crate log; #[phase(plugin, link)] extern crate syntax; extern crate serialize; diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index d143d05acfe..971379b8dd2 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -20,13 +20,13 @@ use rustc_trans::back::link; use driver; use rustc::middle::ty; -use rustc::middle::borrowck::{mod, FnPartsWithCFG}; -use rustc::middle::borrowck::graphviz as borrowck_dot; use rustc::middle::cfg; use rustc::middle::cfg::graphviz::LabelledCFG; use rustc::session::Session; use rustc::session::config::{mod, Input}; use rustc::util::ppaux; +use rustc_borrowck as borrowck; +use rustc_borrowck::graphviz as borrowck_dot; use syntax::ast; use syntax::ast_map::{mod, blocks, NodePrinter}; @@ -565,7 +565,7 @@ fn print_flowgraph(variants: Vec, return Ok(()) } blocks::FnLikeCode(fn_like) => { - let fn_parts = FnPartsWithCFG::from_fn_like(&fn_like, &cfg); + let fn_parts = borrowck::FnPartsWithCFG::from_fn_like(&fn_like, &cfg); let (bccx, analysis_data) = borrowck::build_borrowck_dataflow_data_for_fn(ty_cx, fn_parts);