Skip to content

Separate borrowck into its own crate and remove dead code as well. #19582

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 1 commit into from
Dec 13, 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
10 changes: 6 additions & 4 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

######################################################################
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<MoveError<'tcx>>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,8 +54,6 @@ pub mod check_loans;

pub mod gather_loans;

pub mod graphviz;

pub mod move_data;

#[deriving(Clone)]
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Loading