auto merge of #19582 : nikomatsakis/rust/crateification, r=alexcrichton

r? @alexcrichton
This commit is contained in:
bors 2014-12-13 20:02:15 +00:00
commit 567b90ff09
18 changed files with 139 additions and 152 deletions

View file

@ -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.

View file

@ -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)
######################################################################

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -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,

View file

@ -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>>>

View file

@ -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;

View file

@ -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",

View file

@ -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 {

View file

@ -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)]

View file

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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;

View file

@ -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));

View file

@ -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;

View file

@ -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<W:io::Writer>(variants: Vec<borrowck_dot::Variant>,
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);