librustc: De-export front, borrowck, and typeck/check. rs=deexporting
This commit is contained in:
parent
2ea2628ca9
commit
c25703ccb8
@ -12,8 +12,6 @@
|
||||
// and injected into each crate the compiler builds. Keep it small.
|
||||
|
||||
mod intrinsic {
|
||||
#[legacy_exports];
|
||||
|
||||
pub use intrinsic::rusti::visit_tydesc;
|
||||
|
||||
// FIXME (#3727): remove this when the interface has settled and the
|
||||
@ -30,7 +28,7 @@ pub enum TyDesc = {
|
||||
// Remaining fields not listed
|
||||
};
|
||||
|
||||
trait TyVisitor {
|
||||
pub trait TyVisitor {
|
||||
fn visit_bot(&self) -> bool;
|
||||
fn visit_nil(&self) -> bool;
|
||||
fn visit_bool(&self) -> bool;
|
||||
@ -125,9 +123,8 @@ fn visit_leave_fn(&self, purity: uint, proto: uint,
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
extern mod rusti {
|
||||
#[legacy_exports];
|
||||
fn get_tydesc<T>() -> *();
|
||||
fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor);
|
||||
pub extern mod rusti {
|
||||
pub fn get_tydesc<T>() -> *();
|
||||
pub fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor);
|
||||
}
|
||||
}
|
||||
|
@ -193,8 +193,6 @@ fn add_test_module(cx: test_ctxt, +m: ast::_mod) -> ast::_mod {
|
||||
We're going to be building a module that looks more or less like:
|
||||
|
||||
mod __test {
|
||||
#[legacy_exports];
|
||||
|
||||
fn main(args: ~[str]) -> int {
|
||||
std::test::test_main(args, tests())
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use middle::borrowck::{Loan, bckerr, borrowck_ctxt, cmt, inherent_mutability};
|
||||
use middle::borrowck::{Loan, bckerr, borrowck_ctxt, inherent_mutability};
|
||||
use middle::borrowck::{req_maps, root_map_key, save_and_restore};
|
||||
use middle::mem_categorization::{cat_arg, cat_binding, cat_comp, cat_deref};
|
||||
use middle::mem_categorization::{cat_local, cat_rvalue, cat_self};
|
||||
use middle::mem_categorization::{cat_special, gc_ptr, loan_path, lp_arg};
|
||||
use middle::mem_categorization::{cat_special, cmt, gc_ptr, loan_path, lp_arg};
|
||||
use middle::mem_categorization::{lp_comp, lp_deref, lp_local};
|
||||
use middle::ty::{CopyValue, MoveValue, ReadValue};
|
||||
use middle::ty;
|
||||
@ -41,8 +41,6 @@
|
||||
use syntax::print::pprust;
|
||||
use syntax::visit;
|
||||
|
||||
export check_loans;
|
||||
|
||||
enum check_loan_ctxt = @{
|
||||
bccx: borrowck_ctxt,
|
||||
req_maps: req_maps,
|
||||
@ -65,9 +63,9 @@ enum purity_cause {
|
||||
pc_cmt(bckerr)
|
||||
}
|
||||
|
||||
fn check_loans(bccx: borrowck_ctxt,
|
||||
req_maps: req_maps,
|
||||
crate: @ast::crate) {
|
||||
pub fn check_loans(bccx: borrowck_ctxt,
|
||||
req_maps: req_maps,
|
||||
crate: @ast::crate) {
|
||||
let clcx = check_loan_ctxt(@{bccx: bccx,
|
||||
req_maps: req_maps,
|
||||
reported: HashMap(),
|
||||
|
@ -40,8 +40,6 @@
|
||||
use syntax::print::pprust;
|
||||
use syntax::visit;
|
||||
|
||||
export gather_loans;
|
||||
|
||||
/// Context used while gathering loans:
|
||||
///
|
||||
/// - `bccx`: the the borrow check context
|
||||
@ -76,7 +74,7 @@ enum gather_loan_ctxt = @{bccx: borrowck_ctxt,
|
||||
mut root_ub: ast::node_id,
|
||||
mut ignore_adjustments: LinearSet<ast::node_id>};
|
||||
|
||||
fn gather_loans(bccx: borrowck_ctxt, crate: @ast::crate) -> req_maps {
|
||||
pub fn gather_loans(bccx: borrowck_ctxt, crate: @ast::crate) -> req_maps {
|
||||
let glcx = gather_loan_ctxt(@{bccx: bccx,
|
||||
req_maps: {req_loan_map: HashMap(),
|
||||
pure_map: HashMap()},
|
||||
|
@ -43,13 +43,13 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use middle::borrowck::{Loan, bckerr, bckres, borrowck_ctxt, cmt, err_mutbl};
|
||||
use middle::borrowck::{Loan, bckerr, bckres, borrowck_ctxt, err_mutbl};
|
||||
use middle::borrowck::{err_out_of_scope};
|
||||
use middle::mem_categorization::{cat_arg, cat_binding, cat_discr, cat_comp};
|
||||
use middle::mem_categorization::{cat_deref, cat_discr, cat_local, cat_self};
|
||||
use middle::mem_categorization::{cat_special, cat_stack_upvar, comp_field};
|
||||
use middle::mem_categorization::{comp_index, comp_variant, gc_ptr};
|
||||
use middle::mem_categorization::{region_ptr};
|
||||
use middle::mem_categorization::{cat_special, cat_stack_upvar, cmt};
|
||||
use middle::mem_categorization::{comp_field, comp_index, comp_variant};
|
||||
use middle::mem_categorization::{gc_ptr, region_ptr};
|
||||
use middle::ty;
|
||||
use util::common::indenter;
|
||||
|
||||
@ -57,8 +57,6 @@
|
||||
use syntax::ast::{m_const, m_imm, m_mutbl};
|
||||
use syntax::ast;
|
||||
|
||||
export public_methods;
|
||||
|
||||
impl borrowck_ctxt {
|
||||
fn loan(cmt: cmt,
|
||||
scope_region: ty::Region,
|
||||
|
@ -224,8 +224,6 @@
|
||||
given a memory location and not used as immediates.
|
||||
*/
|
||||
|
||||
#[legacy_exports];
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use middle::liveness;
|
||||
@ -251,20 +249,16 @@
|
||||
use syntax::print::pprust;
|
||||
use syntax::visit;
|
||||
|
||||
#[legacy_exports]
|
||||
pub mod check_loans;
|
||||
#[legacy_exports]
|
||||
pub mod gather_loans;
|
||||
#[legacy_exports]
|
||||
pub mod loan;
|
||||
#[legacy_exports]
|
||||
pub mod preserve;
|
||||
|
||||
fn check_crate(tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
last_use_map: liveness::last_use_map,
|
||||
crate: @ast::crate)
|
||||
-> (root_map, mutbl_map, write_guard_map) {
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
last_use_map: liveness::last_use_map,
|
||||
crate: @ast::crate)
|
||||
-> (root_map, mutbl_map, write_guard_map) {
|
||||
|
||||
let bccx = borrowck_ctxt_(@{tcx: tcx,
|
||||
method_map: method_map,
|
||||
@ -308,26 +302,26 @@ fn make_stat(bccx: borrowck_ctxt, stat: uint) -> ~str {
|
||||
// ----------------------------------------------------------------------
|
||||
// Type definitions
|
||||
|
||||
type borrowck_ctxt_ = {tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
last_use_map: liveness::last_use_map,
|
||||
root_map: root_map,
|
||||
mutbl_map: mutbl_map,
|
||||
write_guard_map: write_guard_map,
|
||||
stmt_map: stmt_set,
|
||||
pub type borrowck_ctxt_ = {tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
last_use_map: liveness::last_use_map,
|
||||
root_map: root_map,
|
||||
mutbl_map: mutbl_map,
|
||||
write_guard_map: write_guard_map,
|
||||
stmt_map: stmt_set,
|
||||
|
||||
// Statistics:
|
||||
mut loaned_paths_same: uint,
|
||||
mut loaned_paths_imm: uint,
|
||||
mut stable_paths: uint,
|
||||
mut req_pure_paths: uint,
|
||||
mut guaranteed_paths: uint};
|
||||
// Statistics:
|
||||
mut loaned_paths_same: uint,
|
||||
mut loaned_paths_imm: uint,
|
||||
mut stable_paths: uint,
|
||||
mut req_pure_paths: uint,
|
||||
mut guaranteed_paths: uint};
|
||||
|
||||
enum borrowck_ctxt {
|
||||
pub enum borrowck_ctxt {
|
||||
borrowck_ctxt_(@borrowck_ctxt_)
|
||||
}
|
||||
|
||||
struct RootInfo {
|
||||
pub struct RootInfo {
|
||||
scope: ast::node_id,
|
||||
// This will be true if we need to freeze this box at runtime. This will
|
||||
// result in a call to `borrow_as_imm()` and `return_to_mut()`.
|
||||
@ -337,7 +331,7 @@ struct RootInfo {
|
||||
// a map mapping id's of expressions of gc'd type (@T, @[], etc) where
|
||||
// the box needs to be kept live to the id of the scope for which they
|
||||
// must stay live.
|
||||
type root_map = HashMap<root_map_key, RootInfo>;
|
||||
pub type root_map = HashMap<root_map_key, RootInfo>;
|
||||
|
||||
// the keys to the root map combine the `id` of the expression with
|
||||
// the number of types that it is autodereferenced. So, for example,
|
||||
@ -345,21 +339,22 @@ struct RootInfo {
|
||||
// entry {id:x, derefs:0} to refer to `x` itself, `{id:x, derefs:1}`
|
||||
// to refer to the deref of the unique pointer, and so on.
|
||||
#[deriving_eq]
|
||||
struct root_map_key {
|
||||
pub struct root_map_key {
|
||||
id: ast::node_id,
|
||||
derefs: uint
|
||||
}
|
||||
|
||||
// set of ids of local vars / formal arguments that are modified / moved.
|
||||
// this is used in trans for optimization purposes.
|
||||
type mutbl_map = HashMap<ast::node_id, ()>;
|
||||
pub type mutbl_map = HashMap<ast::node_id, ()>;
|
||||
|
||||
// A set containing IDs of expressions of gc'd type that need to have a write
|
||||
// guard.
|
||||
type write_guard_map = HashMap<root_map_key, ()>;
|
||||
pub type write_guard_map = HashMap<root_map_key, ()>;
|
||||
|
||||
// Errors that can occur"]
|
||||
enum bckerr_code {
|
||||
// Errors that can occur
|
||||
#[deriving_eq]
|
||||
pub enum bckerr_code {
|
||||
err_mut_uniq,
|
||||
err_mut_variant,
|
||||
err_root_not_permitted,
|
||||
@ -368,61 +363,16 @@ enum bckerr_code {
|
||||
err_out_of_scope(ty::Region, ty::Region) // superscope, subscope
|
||||
}
|
||||
|
||||
impl bckerr_code : cmp::Eq {
|
||||
pure fn eq(&self, other: &bckerr_code) -> bool {
|
||||
match (*self) {
|
||||
err_mut_uniq => {
|
||||
match (*other) {
|
||||
err_mut_uniq => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
err_mut_variant => {
|
||||
match (*other) {
|
||||
err_mut_variant => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
err_root_not_permitted => {
|
||||
match (*other) {
|
||||
err_root_not_permitted => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
err_mutbl(e0a) => {
|
||||
match (*other) {
|
||||
err_mutbl(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
err_out_of_root_scope(e0a, e1a) => {
|
||||
match (*other) {
|
||||
err_out_of_root_scope(e0b, e1b) =>
|
||||
e0a == e0b && e1a == e1b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
err_out_of_scope(e0a, e1a) => {
|
||||
match (*other) {
|
||||
err_out_of_scope(e0b, e1b) => e0a == e0b && e1a == e1b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pure fn ne(&self, other: &bckerr_code) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
// Combination of an error code and the categorization of the expression
|
||||
// that caused it
|
||||
#[deriving_eq]
|
||||
struct bckerr {
|
||||
pub struct bckerr {
|
||||
cmt: cmt,
|
||||
code: bckerr_code
|
||||
}
|
||||
|
||||
// shorthand for something that fails with `bckerr` or succeeds with `T`
|
||||
type bckres<T> = Result<T, bckerr>;
|
||||
pub type bckres<T> = Result<T, bckerr>;
|
||||
|
||||
/// a complete record of a loan that was granted
|
||||
pub struct Loan {lp: @loan_path, cmt: cmt, mutbl: ast::mutability}
|
||||
@ -438,7 +388,8 @@ pub struct Loan {lp: @loan_path, cmt: cmt, mutbl: ast::mutability}
|
||||
pure_map: HashMap<ast::node_id, bckerr>
|
||||
};
|
||||
|
||||
fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T, f: fn() -> U) -> U {
|
||||
pub fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T,
|
||||
f: fn() -> U) -> U {
|
||||
let old_save_and_restore_t = *save_and_restore_t;
|
||||
let u = f();
|
||||
*save_and_restore_t = old_save_and_restore_t;
|
||||
@ -447,20 +398,20 @@ fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T, f: fn() -> U) -> U {
|
||||
|
||||
/// Creates and returns a new root_map
|
||||
|
||||
impl root_map_key : to_bytes::IterBytes {
|
||||
pub impl root_map_key : to_bytes::IterBytes {
|
||||
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f);
|
||||
}
|
||||
}
|
||||
|
||||
fn root_map() -> root_map {
|
||||
pub fn root_map() -> root_map {
|
||||
return HashMap();
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
// Misc
|
||||
|
||||
impl borrowck_ctxt {
|
||||
pub impl borrowck_ctxt {
|
||||
fn is_subregion_of(r_sub: ty::Region, r_sup: ty::Region) -> bool {
|
||||
region::is_subregion_of(self.tcx.region_map, r_sub, r_sup)
|
||||
}
|
||||
@ -632,7 +583,7 @@ fn loan_to_repr(loan: &Loan) -> ~str {
|
||||
// assuming it is embedded in an immutable context. In general, the
|
||||
// mutability can be "overridden" if the component is embedded in a
|
||||
// mutable structure.
|
||||
fn inherent_mutability(ck: comp_kind) -> mutability {
|
||||
pub fn inherent_mutability(ck: comp_kind) -> mutability {
|
||||
match ck {
|
||||
comp_tuple | comp_anon_field | comp_variant(_) => m_imm,
|
||||
comp_field(_, m) | comp_index(_, m) => m
|
||||
|
@ -16,22 +16,21 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use middle::borrowck::{RootInfo, bckerr, bckerr_code, bckres, borrowck_ctxt};
|
||||
use middle::borrowck::{cmt, err_mut_uniq, err_mut_variant};
|
||||
use middle::borrowck::{err_mut_uniq, err_mut_variant};
|
||||
use middle::borrowck::{err_out_of_root_scope, err_out_of_scope};
|
||||
use middle::borrowck::{err_root_not_permitted, root_map_key};
|
||||
use middle::mem_categorization::{cat_arg, cat_binding, cat_comp, cat_deref};
|
||||
use middle::mem_categorization::{cat_discr, cat_local, cat_self, cat_special};
|
||||
use middle::mem_categorization::{cat_stack_upvar, comp_field, comp_index};
|
||||
use middle::mem_categorization::{comp_variant, gc_ptr, region_ptr};
|
||||
use middle::mem_categorization::{cat_stack_upvar, cmt, comp_field};
|
||||
use middle::mem_categorization::{comp_index, comp_variant, gc_ptr};
|
||||
use middle::mem_categorization::{region_ptr};
|
||||
use middle::ty;
|
||||
use util::common::indenter;
|
||||
|
||||
use syntax::ast::{m_const, m_imm, m_mutbl};
|
||||
use syntax::ast;
|
||||
|
||||
export public_methods, preserve_condition, pc_ok, pc_if_pure;
|
||||
|
||||
enum preserve_condition {
|
||||
pub enum preserve_condition {
|
||||
pc_ok,
|
||||
pc_if_pure(bckerr)
|
||||
}
|
||||
|
@ -27,10 +27,10 @@
|
||||
use syntax::codemap::span;
|
||||
use syntax::print::pprust;
|
||||
|
||||
fn check_match(fcx: @fn_ctxt,
|
||||
expr: @ast::expr,
|
||||
discrim: @ast::expr,
|
||||
arms: ~[ast::arm]) -> bool {
|
||||
pub fn check_match(fcx: @fn_ctxt,
|
||||
expr: @ast::expr,
|
||||
discrim: @ast::expr,
|
||||
arms: ~[ast::arm]) -> bool {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
let mut bot;
|
||||
|
||||
@ -68,15 +68,15 @@ fn check_match(fcx: @fn_ctxt,
|
||||
return bot;
|
||||
}
|
||||
|
||||
struct pat_ctxt {
|
||||
pub struct pat_ctxt {
|
||||
fcx: @fn_ctxt,
|
||||
map: PatIdMap,
|
||||
match_region: ty::Region, // Region for the match as a whole
|
||||
block_region: ty::Region, // Region for the block of the arm
|
||||
}
|
||||
|
||||
fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
||||
+subpats: Option<~[@ast::pat]>, expected: ty::t) {
|
||||
pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
||||
+subpats: Option<~[@ast::pat]>, expected: ty::t) {
|
||||
|
||||
// Typecheck the path.
|
||||
let fcx = pcx.fcx;
|
||||
@ -197,14 +197,14 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
||||
/// `substitutions` are the type substitutions applied to this struct type
|
||||
/// (e.g. K,V in HashMap<K,V>).
|
||||
/// `etc` is true if the pattern said '...' and false otherwise.
|
||||
fn check_struct_pat_fields(pcx: pat_ctxt,
|
||||
span: span,
|
||||
path: @ast::path,
|
||||
fields: ~[ast::field_pat],
|
||||
class_fields: ~[ty::field_ty],
|
||||
class_id: ast::def_id,
|
||||
substitutions: &ty::substs,
|
||||
etc: bool) {
|
||||
pub fn check_struct_pat_fields(pcx: pat_ctxt,
|
||||
span: span,
|
||||
path: @ast::path,
|
||||
fields: ~[ast::field_pat],
|
||||
class_fields: ~[ty::field_ty],
|
||||
class_id: ast::def_id,
|
||||
substitutions: &ty::substs,
|
||||
etc: bool) {
|
||||
let tcx = pcx.fcx.ccx.tcx;
|
||||
|
||||
// Index the class fields.
|
||||
@ -249,10 +249,10 @@ fn check_struct_pat_fields(pcx: pat_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
fn check_struct_pat(pcx: pat_ctxt, pat_id: ast::node_id, span: span,
|
||||
expected: ty::t, path: @ast::path,
|
||||
+fields: ~[ast::field_pat], etc: bool,
|
||||
class_id: ast::def_id, substitutions: &ty::substs) {
|
||||
pub fn check_struct_pat(pcx: pat_ctxt, pat_id: ast::node_id, span: span,
|
||||
expected: ty::t, path: @ast::path,
|
||||
+fields: ~[ast::field_pat], etc: bool,
|
||||
class_id: ast::def_id, substitutions: &ty::substs) {
|
||||
let fcx = pcx.fcx;
|
||||
let tcx = pcx.fcx.ccx.tcx;
|
||||
|
||||
@ -287,15 +287,15 @@ fn check_struct_pat(pcx: pat_ctxt, pat_id: ast::node_id, span: span,
|
||||
substitutions, etc);
|
||||
}
|
||||
|
||||
fn check_struct_like_enum_variant_pat(pcx: pat_ctxt,
|
||||
pat_id: ast::node_id,
|
||||
span: span,
|
||||
expected: ty::t,
|
||||
path: @ast::path,
|
||||
+fields: ~[ast::field_pat],
|
||||
etc: bool,
|
||||
enum_id: ast::def_id,
|
||||
substitutions: &ty::substs) {
|
||||
pub fn check_struct_like_enum_variant_pat(pcx: pat_ctxt,
|
||||
pat_id: ast::node_id,
|
||||
span: span,
|
||||
expected: ty::t,
|
||||
path: @ast::path,
|
||||
+fields: ~[ast::field_pat],
|
||||
etc: bool,
|
||||
enum_id: ast::def_id,
|
||||
substitutions: &ty::substs) {
|
||||
let fcx = pcx.fcx;
|
||||
let tcx = pcx.fcx.ccx.tcx;
|
||||
|
||||
@ -325,7 +325,7 @@ fn check_struct_like_enum_variant_pat(pcx: pat_ctxt,
|
||||
|
||||
// Pattern checking is top-down rather than bottom-up so that bindings get
|
||||
// their types immediately.
|
||||
fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
||||
pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
||||
let fcx = pcx.fcx;
|
||||
let tcx = pcx.fcx.ccx.tcx;
|
||||
|
||||
|
@ -20,16 +20,16 @@
|
||||
|
||||
// Requires that the two types unify, and prints an error message if they
|
||||
// don't.
|
||||
fn suptype(fcx: @fn_ctxt, sp: span,
|
||||
expected: ty::t, actual: ty::t) {
|
||||
pub fn suptype(fcx: @fn_ctxt, sp: span,
|
||||
expected: ty::t, actual: ty::t) {
|
||||
suptype_with_fn(fcx, sp, expected, actual,
|
||||
|sp, e, a, s| { fcx.report_mismatched_types(sp, e, a, s) })
|
||||
}
|
||||
|
||||
fn suptype_with_fn(fcx: @fn_ctxt,
|
||||
sp: span,
|
||||
expected: ty::t, actual: ty::t,
|
||||
handle_err: fn(span, ty::t, ty::t, &ty::type_err)) {
|
||||
pub fn suptype_with_fn(fcx: @fn_ctxt,
|
||||
sp: span,
|
||||
expected: ty::t, actual: ty::t,
|
||||
handle_err: fn(span, ty::t, ty::t, &ty::type_err)) {
|
||||
// n.b.: order of actual, expected is reversed
|
||||
match infer::mk_subty(fcx.infcx(), false, sp,
|
||||
actual, expected) {
|
||||
@ -40,7 +40,7 @@ fn suptype_with_fn(fcx: @fn_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
fn eqtype(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t) {
|
||||
pub fn eqtype(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t) {
|
||||
match infer::mk_eqty(fcx.infcx(), false, sp, actual, expected) {
|
||||
Ok(()) => { /* ok */ }
|
||||
Err(ref err) => {
|
||||
@ -50,10 +50,10 @@ fn eqtype(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t) {
|
||||
}
|
||||
|
||||
// Checks that the type `actual` can be coerced to `expected`.
|
||||
fn coerce(fcx: @fn_ctxt,
|
||||
sp: span,
|
||||
expected: ty::t,
|
||||
expr: @ast::expr) {
|
||||
pub fn coerce(fcx: @fn_ctxt,
|
||||
sp: span,
|
||||
expected: ty::t,
|
||||
expr: @ast::expr) {
|
||||
let expr_ty = fcx.expr_ty(expr);
|
||||
match fcx.mk_assignty(expr, expr_ty, expected) {
|
||||
result::Ok(()) => { /* ok */ }
|
||||
|
@ -111,7 +111,7 @@ trait `ToStr` imported, and I call `to_str()` on a value of type `T`,
|
||||
use syntax::ast_util::dummy_sp;
|
||||
use syntax::codemap::span;
|
||||
|
||||
fn lookup(
|
||||
pub fn lookup(
|
||||
fcx: @fn_ctxt,
|
||||
|
||||
// In a call `a.b::<X, Y, ...>(...)`:
|
||||
@ -142,7 +142,7 @@ fn lookup(
|
||||
return move mme;
|
||||
}
|
||||
|
||||
struct LookupContext {
|
||||
pub struct LookupContext {
|
||||
fcx: @fn_ctxt,
|
||||
expr: @ast::expr,
|
||||
self_expr: @ast::expr,
|
||||
@ -157,8 +157,9 @@ struct LookupContext {
|
||||
|
||||
/**
|
||||
* A potential method that might be called, assuming the receiver
|
||||
* is of a suitable type. */
|
||||
struct Candidate {
|
||||
* is of a suitable type.
|
||||
*/
|
||||
pub struct Candidate {
|
||||
rcvr_ty: ty::t,
|
||||
rcvr_substs: ty::substs,
|
||||
explicit_self: ast::self_ty_,
|
||||
@ -175,12 +176,12 @@ struct Candidate {
|
||||
* How the self type should be transformed according to the form of explicit
|
||||
* self provided by the method.
|
||||
*/
|
||||
enum TransformTypeFlag {
|
||||
pub enum TransformTypeFlag {
|
||||
TransformTypeNormally,
|
||||
TransformTypeForObject,
|
||||
}
|
||||
|
||||
impl LookupContext {
|
||||
pub impl LookupContext {
|
||||
fn do_lookup(&self, self_ty: ty::t) -> Option<method_map_entry> {
|
||||
debug!("do_lookup(self_ty=%s, expr=%s, self_expr=%s)",
|
||||
self.ty_to_str(self_ty),
|
||||
@ -1253,12 +1254,12 @@ fn bug(&self, +s: ~str) -> ! {
|
||||
}
|
||||
}
|
||||
|
||||
fn transform_self_type_for_method(tcx: ty::ctxt,
|
||||
self_region: Option<ty::Region>,
|
||||
impl_ty: ty::t,
|
||||
self_type: ast::self_ty_,
|
||||
flag: TransformTypeFlag)
|
||||
-> ty::t {
|
||||
pub fn transform_self_type_for_method(tcx: ty::ctxt,
|
||||
self_region: Option<ty::Region>,
|
||||
impl_ty: ty::t,
|
||||
self_type: ast::self_ty_,
|
||||
flag: TransformTypeFlag)
|
||||
-> ty::t {
|
||||
match self_type {
|
||||
sty_static => {
|
||||
tcx.sess.bug(~"calling transform_self_type_for_method on \
|
||||
@ -1291,6 +1292,6 @@ fn transform_self_type_for_method(tcx: ty::ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_mode_from_self_type(self_type: ast::self_ty_) -> ast::rmode {
|
||||
pub fn get_mode_from_self_type(self_type: ast::self_ty_) -> ast::rmode {
|
||||
match self_type { sty_value => by_copy, _ => by_ref }
|
||||
}
|
||||
|
@ -131,45 +131,15 @@
|
||||
use syntax::visit;
|
||||
use syntax;
|
||||
|
||||
export _match;
|
||||
export vtable;
|
||||
export writeback;
|
||||
export regionmanip;
|
||||
export regionck;
|
||||
export demand;
|
||||
export method;
|
||||
export fn_ctxt;
|
||||
export impl_self_ty;
|
||||
export DerefArgs;
|
||||
export DontDerefArgs;
|
||||
export DoDerefArgs;
|
||||
export check_item_types;
|
||||
export check_block;
|
||||
export check_expr_has_type;
|
||||
export fn_ctxt;
|
||||
export lookup_def;
|
||||
export structure_of;
|
||||
export self_info;
|
||||
export structurally_resolved_type;
|
||||
export instantiate_path;
|
||||
export valid_range_bounds;
|
||||
|
||||
#[legacy_exports]
|
||||
pub mod _match;
|
||||
#[legacy_exports]
|
||||
pub mod vtable;
|
||||
#[legacy_exports]
|
||||
pub mod writeback;
|
||||
#[legacy_exports]
|
||||
pub mod regionmanip;
|
||||
#[legacy_exports]
|
||||
pub mod regionck;
|
||||
#[legacy_exports]
|
||||
pub mod demand;
|
||||
#[legacy_exports]
|
||||
pub mod method;
|
||||
|
||||
type self_info = {
|
||||
pub type self_info = {
|
||||
self_ty: ty::t,
|
||||
self_id: ast::node_id,
|
||||
def_id: ast::def_id,
|
||||
@ -264,7 +234,7 @@ fn blank_fn_ctxt(ccx: @crate_ctxt, rty: ty::t,
|
||||
}
|
||||
}
|
||||
|
||||
fn check_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
|
||||
pub fn check_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
|
||||
let visit = visit::mk_simple_visitor(@visit::SimpleVisitor {
|
||||
visit_item: |a| check_item(ccx, a),
|
||||
.. *visit::default_simple_visitor()
|
||||
@ -984,12 +954,12 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t {
|
||||
}
|
||||
}
|
||||
|
||||
fn valid_range_bounds(ccx: @crate_ctxt, from: @ast::expr, to: @ast::expr)
|
||||
pub fn valid_range_bounds(ccx: @crate_ctxt, from: @ast::expr, to: @ast::expr)
|
||||
-> bool {
|
||||
const_eval::compare_lit_exprs(ccx.tcx, from, to) <= 0
|
||||
}
|
||||
|
||||
fn check_expr_has_type(
|
||||
pub fn check_expr_has_type(
|
||||
fcx: @fn_ctxt, expr: @ast::expr,
|
||||
expected: ty::t) -> bool
|
||||
{
|
||||
@ -2630,7 +2600,7 @@ fn check_block_no_value(fcx: @fn_ctxt, blk: ast::blk) -> bool {
|
||||
return bot;
|
||||
}
|
||||
|
||||
fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
|
||||
pub fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
|
||||
check_block_with_expected(fcx0, blk, None)
|
||||
}
|
||||
|
||||
@ -2831,7 +2801,7 @@ fn do_check(ccx: @crate_ctxt, sp: span, vs: ~[ast::variant],
|
||||
check_instantiable(ccx.tcx, sp, id);
|
||||
}
|
||||
|
||||
fn lookup_def(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> ast::def {
|
||||
pub fn lookup_def(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> ast::def {
|
||||
lookup_def_ccx(fcx.ccx, sp, id)
|
||||
}
|
||||
|
||||
@ -2901,12 +2871,12 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
|
||||
|
||||
// Instantiates the given path, which must refer to an item with the given
|
||||
// number of type parameters and type.
|
||||
fn instantiate_path(fcx: @fn_ctxt,
|
||||
pth: @ast::path,
|
||||
tpt: ty_param_bounds_and_ty,
|
||||
span: span,
|
||||
node_id: ast::node_id,
|
||||
region_lb: ty::Region) {
|
||||
pub fn instantiate_path(fcx: @fn_ctxt,
|
||||
pth: @ast::path,
|
||||
tpt: ty_param_bounds_and_ty,
|
||||
span: span,
|
||||
node_id: ast::node_id,
|
||||
region_lb: ty::Region) {
|
||||
debug!(">>> instantiate_path");
|
||||
|
||||
let ty_param_count = vec::len(*tpt.bounds);
|
||||
@ -2961,7 +2931,8 @@ fn instantiate_path(fcx: @fn_ctxt,
|
||||
|
||||
// Resolves `typ` by a single level if `typ` is a type variable. If no
|
||||
// resolution is possible, then an error is reported.
|
||||
fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t {
|
||||
pub fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t)
|
||||
-> ty::t {
|
||||
match infer::resolve_type(fcx.infcx(), tp, force_tvar) {
|
||||
Ok(t_s) if !ty::type_is_ty_var(t_s) => return t_s,
|
||||
_ => {
|
||||
@ -2974,7 +2945,7 @@ fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t {
|
||||
}
|
||||
|
||||
// Returns the one-level-deep structure of the given type.
|
||||
fn structure_of(fcx: @fn_ctxt, sp: span, typ: ty::t) -> ty::sty {
|
||||
pub fn structure_of(fcx: @fn_ctxt, sp: span, typ: ty::t) -> ty::sty {
|
||||
/*bad*/copy ty::get(structurally_resolved_type(fcx, sp, typ)).sty
|
||||
}
|
||||
|
||||
|
@ -49,10 +49,10 @@
|
||||
use syntax::print::pprust;
|
||||
use syntax::visit;
|
||||
|
||||
enum rcx { rcx_({fcx: @fn_ctxt, mut errors_reported: uint}) }
|
||||
type rvt = visit::vt<@rcx>;
|
||||
pub enum rcx { rcx_({fcx: @fn_ctxt, mut errors_reported: uint}) }
|
||||
pub type rvt = visit::vt<@rcx>;
|
||||
|
||||
fn encl_region_of_def(fcx: @fn_ctxt, def: ast::def) -> ty::Region {
|
||||
pub fn encl_region_of_def(fcx: @fn_ctxt, def: ast::def) -> ty::Region {
|
||||
let tcx = fcx.tcx();
|
||||
match def {
|
||||
def_local(node_id, _) | def_arg(node_id, _, _) |
|
||||
@ -72,7 +72,7 @@ fn encl_region_of_def(fcx: @fn_ctxt, def: ast::def) -> ty::Region {
|
||||
}
|
||||
}
|
||||
|
||||
impl @rcx {
|
||||
pub impl @rcx {
|
||||
fn resolve_type(unresolved_ty: ty::t) -> ty::t {
|
||||
/*!
|
||||
* Try to resolve the type for the given node, returning
|
||||
@ -115,22 +115,22 @@ fn resolve_node_type(id: ast::node_id) -> ty::t {
|
||||
}
|
||||
}
|
||||
|
||||
fn regionck_expr(fcx: @fn_ctxt, e: @ast::expr) {
|
||||
pub fn regionck_expr(fcx: @fn_ctxt, e: @ast::expr) {
|
||||
let rcx = rcx_({fcx:fcx, mut errors_reported: 0});
|
||||
let v = regionck_visitor();
|
||||
(v.visit_expr)(e, @(move rcx), v);
|
||||
fcx.infcx().resolve_regions();
|
||||
}
|
||||
|
||||
fn regionck_fn(fcx: @fn_ctxt,
|
||||
blk: ast::blk) {
|
||||
pub fn regionck_fn(fcx: @fn_ctxt,
|
||||
blk: ast::blk) {
|
||||
let rcx = rcx_({fcx:fcx, mut errors_reported: 0});
|
||||
let v = regionck_visitor();
|
||||
(v.visit_block)(blk, @(move rcx), v);
|
||||
fcx.infcx().resolve_regions();
|
||||
}
|
||||
|
||||
fn regionck_visitor() -> rvt {
|
||||
pub fn regionck_visitor() -> rvt {
|
||||
visit::mk_vt(@visit::Visitor {visit_item: visit_item,
|
||||
visit_stmt: visit_stmt,
|
||||
visit_expr: visit_expr,
|
||||
@ -139,11 +139,11 @@ fn regionck_visitor() -> rvt {
|
||||
.. *visit::default_visitor()})
|
||||
}
|
||||
|
||||
fn visit_item(_item: @ast::item, &&_rcx: @rcx, _v: rvt) {
|
||||
pub fn visit_item(_item: @ast::item, &&_rcx: @rcx, _v: rvt) {
|
||||
// Ignore items
|
||||
}
|
||||
|
||||
fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) {
|
||||
pub fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) {
|
||||
// Check to make sure that the regions in all local variables are
|
||||
// within scope.
|
||||
//
|
||||
@ -174,11 +174,11 @@ fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_block(b: ast::blk, &&rcx: @rcx, v: rvt) {
|
||||
pub fn visit_block(b: ast::blk, &&rcx: @rcx, v: rvt) {
|
||||
visit::visit_block(b, rcx, v);
|
||||
}
|
||||
|
||||
fn visit_expr(expr: @ast::expr, &&rcx: @rcx, v: rvt) {
|
||||
pub fn visit_expr(expr: @ast::expr, &&rcx: @rcx, v: rvt) {
|
||||
debug!("visit_expr(e=%s)", rcx.fcx.expr_to_str(expr));
|
||||
|
||||
for rcx.fcx.inh.adjustments.find(expr.id).each |adjustment| {
|
||||
@ -295,11 +295,11 @@ fn visit_expr(expr: @ast::expr, &&rcx: @rcx, v: rvt) {
|
||||
visit::visit_expr(expr, rcx, v);
|
||||
}
|
||||
|
||||
fn visit_stmt(s: @ast::stmt, &&rcx: @rcx, v: rvt) {
|
||||
pub fn visit_stmt(s: @ast::stmt, &&rcx: @rcx, v: rvt) {
|
||||
visit::visit_stmt(s, rcx, v);
|
||||
}
|
||||
|
||||
fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool {
|
||||
pub fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool {
|
||||
/*!
|
||||
*
|
||||
* checks the type of the node `id` and reports an error if it
|
||||
@ -318,10 +318,7 @@ fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool {
|
||||
constrain_regions_in_type_of_node(rcx, id, encl_region, span)
|
||||
}
|
||||
|
||||
fn constrain_auto_ref(
|
||||
rcx: @rcx,
|
||||
expr: @ast::expr)
|
||||
{
|
||||
pub fn constrain_auto_ref(rcx: @rcx, expr: @ast::expr) {
|
||||
/*!
|
||||
*
|
||||
* If `expr` is auto-ref'd (e.g., as part of a borrow), then this
|
||||
@ -365,11 +362,10 @@ fn constrain_auto_ref(
|
||||
}
|
||||
}
|
||||
|
||||
fn constrain_free_variables(
|
||||
pub fn constrain_free_variables(
|
||||
rcx: @rcx,
|
||||
region: ty::Region,
|
||||
expr: @ast::expr)
|
||||
{
|
||||
expr: @ast::expr) {
|
||||
/*!
|
||||
*
|
||||
* Make sure that all free variables referenced inside the closure
|
||||
@ -402,12 +398,11 @@ fn constrain_free_variables(
|
||||
}
|
||||
}
|
||||
|
||||
fn constrain_regions_in_type_of_node(
|
||||
pub fn constrain_regions_in_type_of_node(
|
||||
rcx: @rcx,
|
||||
id: ast::node_id,
|
||||
encl_region: ty::Region,
|
||||
span: span) -> bool
|
||||
{
|
||||
span: span) -> bool {
|
||||
let tcx = rcx.fcx.tcx();
|
||||
|
||||
// Try to resolve the type. If we encounter an error, then typeck
|
||||
@ -420,12 +415,11 @@ fn constrain_regions_in_type_of_node(
|
||||
constrain_regions_in_type(rcx, encl_region, span, ty)
|
||||
}
|
||||
|
||||
fn constrain_regions_in_type(
|
||||
pub fn constrain_regions_in_type(
|
||||
rcx: @rcx,
|
||||
encl_region: ty::Region,
|
||||
span: span,
|
||||
ty: ty::t) -> bool
|
||||
{
|
||||
ty: ty::t) -> bool {
|
||||
/*!
|
||||
*
|
||||
* Requires that any regions which appear in `ty` must be
|
||||
@ -481,7 +475,7 @@ fn constrain_region(rcx: @rcx,
|
||||
}
|
||||
}
|
||||
|
||||
mod guarantor {
|
||||
pub mod guarantor {
|
||||
/*!
|
||||
*
|
||||
* The routines in this module are aiming to deal with the case
|
||||
@ -923,12 +917,11 @@ fn link_ref_bindings_in_pats(rcx: @rcx,
|
||||
|
||||
}
|
||||
|
||||
fn infallibly_mk_subr(rcx: @rcx,
|
||||
a_is_expected: bool,
|
||||
span: span,
|
||||
a: ty::Region,
|
||||
b: ty::Region)
|
||||
{
|
||||
pub fn infallibly_mk_subr(rcx: @rcx,
|
||||
a_is_expected: bool,
|
||||
span: span,
|
||||
a: ty::Region,
|
||||
b: ty::Region) {
|
||||
/*!
|
||||
*
|
||||
* Constrains `a` to be a subregion of `b`. In many cases, we
|
||||
@ -947,4 +940,4 @@ fn infallibly_mk_subr(rcx: @rcx,
|
||||
a, b, e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ pub fn replace_bound_regions_in_fn_ty(
|
||||
self_info: Option<self_info>,
|
||||
fn_ty: &ty::FnTy,
|
||||
mapf: fn(ty::bound_region) -> ty::Region) ->
|
||||
{isr: isr_alist, self_info: Option<self_info>, fn_ty: ty::FnTy}
|
||||
{
|
||||
{isr: isr_alist, self_info: Option<self_info>, fn_ty: ty::FnTy} {
|
||||
let {isr, self_info, fn_sig} =
|
||||
replace_bound_regions_in_fn_sig(
|
||||
tcx, isr, self_info, &fn_ty.sig, mapf);
|
||||
@ -49,8 +48,7 @@ pub fn replace_bound_regions_in_fn_sig(
|
||||
self_info: Option<self_info>,
|
||||
fn_sig: &ty::FnSig,
|
||||
mapf: fn(ty::bound_region) -> ty::Region) ->
|
||||
{isr: isr_alist, self_info: Option<self_info>, fn_sig: ty::FnSig}
|
||||
{
|
||||
{isr: isr_alist, self_info: Option<self_info>, fn_sig: ty::FnSig} {
|
||||
// Take self_info apart; the self_ty part is the only one we want
|
||||
// to update here.
|
||||
let self_ty = self_info.map(|s| s.self_ty);
|
||||
|
@ -55,23 +55,23 @@
|
||||
/// Location info records the span and ID of the expression or item that is
|
||||
/// responsible for this vtable instantiation. (This may not be an expression
|
||||
/// if the vtable instantiation is being performed as part of "deriving".)
|
||||
struct LocationInfo {
|
||||
pub struct LocationInfo {
|
||||
span: span,
|
||||
id: ast::node_id
|
||||
}
|
||||
|
||||
/// A vtable context includes an inference context, a crate context, and a
|
||||
/// callback function to call in case of type error.
|
||||
struct VtableContext {
|
||||
pub struct VtableContext {
|
||||
ccx: @crate_ctxt,
|
||||
infcx: @infer::InferCtxt
|
||||
}
|
||||
|
||||
impl VtableContext {
|
||||
pub impl VtableContext {
|
||||
fn tcx(&const self) -> ty::ctxt { self.ccx.tcx }
|
||||
}
|
||||
|
||||
fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool {
|
||||
pub fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool {
|
||||
vec::any(tps, |bs| {
|
||||
bs.any(|b| {
|
||||
match b { &ty::bound_trait(_) => true, _ => false }
|
||||
@ -79,13 +79,12 @@ fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
fn lookup_vtables(vcx: &VtableContext,
|
||||
location_info: &LocationInfo,
|
||||
bounds: @~[ty::param_bounds],
|
||||
substs: &ty::substs,
|
||||
allow_unsafe: bool,
|
||||
is_early: bool) -> vtable_res
|
||||
{
|
||||
pub fn lookup_vtables(vcx: &VtableContext,
|
||||
location_info: &LocationInfo,
|
||||
bounds: @~[ty::param_bounds],
|
||||
substs: &ty::substs,
|
||||
allow_unsafe: bool,
|
||||
is_early: bool) -> vtable_res {
|
||||
debug!("lookup_vtables(location_info=%?,
|
||||
# bounds=%?, \
|
||||
substs=%s",
|
||||
@ -140,9 +139,9 @@ trait %s for %s",
|
||||
@result
|
||||
}
|
||||
|
||||
fn fixup_substs(vcx: &VtableContext, location_info: &LocationInfo,
|
||||
id: ast::def_id, +substs: ty::substs,
|
||||
is_early: bool) -> Option<ty::substs> {
|
||||
pub fn fixup_substs(vcx: &VtableContext, location_info: &LocationInfo,
|
||||
id: ast::def_id, +substs: ty::substs,
|
||||
is_early: bool) -> Option<ty::substs> {
|
||||
let tcx = vcx.tcx();
|
||||
// use a dummy type just to package up the substs that need fixing up
|
||||
let t = ty::mk_trait(tcx, id, substs, ty::vstore_slice(ty::re_static));
|
||||
@ -154,20 +153,20 @@ fn fixup_substs(vcx: &VtableContext, location_info: &LocationInfo,
|
||||
}
|
||||
}
|
||||
|
||||
fn relate_trait_tys(vcx: &VtableContext, location_info: &LocationInfo,
|
||||
exp_trait_ty: ty::t, act_trait_ty: ty::t) {
|
||||
pub fn relate_trait_tys(vcx: &VtableContext, location_info: &LocationInfo,
|
||||
exp_trait_ty: ty::t, act_trait_ty: ty::t) {
|
||||
demand_suptype(vcx, location_info.span, exp_trait_ty, act_trait_ty)
|
||||
}
|
||||
|
||||
// Look up the vtable to use when treating an item of type `t` as if it has
|
||||
// type `trait_ty`
|
||||
fn lookup_vtable(vcx: &VtableContext,
|
||||
location_info: &LocationInfo,
|
||||
ty: ty::t,
|
||||
trait_ty: ty::t,
|
||||
allow_unsafe: bool,
|
||||
is_early: bool)
|
||||
-> Option<vtable_origin> {
|
||||
pub fn lookup_vtable(vcx: &VtableContext,
|
||||
location_info: &LocationInfo,
|
||||
ty: ty::t,
|
||||
trait_ty: ty::t,
|
||||
allow_unsafe: bool,
|
||||
is_early: bool)
|
||||
-> Option<vtable_origin> {
|
||||
debug!("lookup_vtable(ty=%s, trait_ty=%s)",
|
||||
vcx.infcx.ty_to_str(ty), vcx.infcx.ty_to_str(trait_ty));
|
||||
let _i = indenter();
|
||||
@ -446,11 +445,10 @@ fn lookup_vtable(vcx: &VtableContext,
|
||||
return None;
|
||||
}
|
||||
|
||||
fn fixup_ty(vcx: &VtableContext,
|
||||
location_info: &LocationInfo,
|
||||
ty: ty::t,
|
||||
is_early: bool) -> Option<ty::t>
|
||||
{
|
||||
pub fn fixup_ty(vcx: &VtableContext,
|
||||
location_info: &LocationInfo,
|
||||
ty: ty::t,
|
||||
is_early: bool) -> Option<ty::t> {
|
||||
let tcx = vcx.tcx();
|
||||
match resolve_type(vcx.infcx, ty, resolve_and_force_all_but_regions) {
|
||||
Ok(new_type) => Some(new_type),
|
||||
@ -469,7 +467,7 @@ fn fixup_ty(vcx: &VtableContext,
|
||||
|
||||
// Version of demand::suptype() that takes a vtable context instead of a
|
||||
// function context.
|
||||
fn demand_suptype(vcx: &VtableContext, sp: span, e: ty::t, a: ty::t) {
|
||||
pub fn demand_suptype(vcx: &VtableContext, sp: span, e: ty::t, a: ty::t) {
|
||||
// NB: Order of actual, expected is reversed.
|
||||
match infer::mk_subty(vcx.infcx, false, sp, a, e) {
|
||||
result::Ok(()) => {} // Ok.
|
||||
@ -479,12 +477,12 @@ fn demand_suptype(vcx: &VtableContext, sp: span, e: ty::t, a: ty::t) {
|
||||
}
|
||||
}
|
||||
|
||||
fn connect_trait_tps(vcx: &VtableContext,
|
||||
location_info: &LocationInfo,
|
||||
impl_tys: ~[ty::t],
|
||||
trait_tys: ~[ty::t],
|
||||
impl_did: ast::def_id,
|
||||
vstore: ty::vstore) {
|
||||
pub fn connect_trait_tps(vcx: &VtableContext,
|
||||
location_info: &LocationInfo,
|
||||
impl_tys: ~[ty::t],
|
||||
trait_tys: ~[ty::t],
|
||||
impl_did: ast::def_id,
|
||||
vstore: ty::vstore) {
|
||||
let tcx = vcx.tcx();
|
||||
|
||||
// XXX: This should work for multiple traits.
|
||||
@ -503,21 +501,21 @@ fn connect_trait_tps(vcx: &VtableContext,
|
||||
}
|
||||
}
|
||||
|
||||
fn insert_vtables(ccx: @crate_ctxt, callee_id: ast::node_id,
|
||||
vtables: vtable_res) {
|
||||
pub fn insert_vtables(ccx: @crate_ctxt, callee_id: ast::node_id,
|
||||
vtables: vtable_res) {
|
||||
debug!("insert_vtables(callee_id=%d, vtables=%?)",
|
||||
callee_id, vtables.map(|v| v.to_str(ccx.tcx)));
|
||||
ccx.vtable_map.insert(callee_id, vtables);
|
||||
}
|
||||
|
||||
fn location_info_for_expr(expr: @ast::expr) -> LocationInfo {
|
||||
pub fn location_info_for_expr(expr: @ast::expr) -> LocationInfo {
|
||||
LocationInfo {
|
||||
span: expr.span,
|
||||
id: expr.id
|
||||
}
|
||||
}
|
||||
|
||||
fn early_resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, is_early: bool) {
|
||||
pub fn early_resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, is_early: bool) {
|
||||
debug!("vtable: early_resolve_expr() ex with id %? (early: %b): %s",
|
||||
ex.id, is_early, expr_to_str(ex, fcx.tcx().sess.intr()));
|
||||
let _indent = indenter();
|
||||
@ -710,14 +708,16 @@ fn early_resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, is_early: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) {
|
||||
pub fn resolve_expr(ex: @ast::expr,
|
||||
&&fcx: @fn_ctxt,
|
||||
v: visit::vt<@fn_ctxt>) {
|
||||
early_resolve_expr(ex, fcx, false);
|
||||
visit::visit_expr(ex, fcx, v);
|
||||
}
|
||||
|
||||
// Detect points where a trait-bounded type parameter is
|
||||
// instantiated, resolve the impls for the parameters.
|
||||
fn resolve_in_block(fcx: @fn_ctxt, bl: ast::blk) {
|
||||
pub fn resolve_in_block(fcx: @fn_ctxt, bl: ast::blk) {
|
||||
visit::visit_block(bl, fcx, visit::mk_vt(@visit::Visitor {
|
||||
visit_expr: resolve_expr,
|
||||
visit_item: fn@(_i: @ast::item, &&_e: @fn_ctxt,
|
||||
|
@ -34,12 +34,8 @@
|
||||
use syntax::print::pprust::pat_to_str;
|
||||
use syntax::visit;
|
||||
|
||||
export resolve_type_vars_in_fn;
|
||||
export resolve_type_vars_in_expr;
|
||||
|
||||
fn resolve_type_vars_in_type(fcx: @fn_ctxt, sp: span, typ: ty::t)
|
||||
-> Option<ty::t>
|
||||
{
|
||||
-> Option<ty::t> {
|
||||
if !ty::type_needs_infer(typ) { return Some(typ); }
|
||||
match resolve_type(fcx.infcx(), typ, resolve_all | force_all) {
|
||||
Ok(new_type) => return Some(new_type),
|
||||
@ -251,17 +247,17 @@ fn mk_visitor() -> visit::vt<wb_ctxt> {
|
||||
.. *visit::default_visitor()})
|
||||
}
|
||||
|
||||
fn resolve_type_vars_in_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool {
|
||||
pub fn resolve_type_vars_in_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool {
|
||||
let wbcx = {fcx: fcx, mut success: true};
|
||||
let visit = mk_visitor();
|
||||
(visit.visit_expr)(e, wbcx, visit);
|
||||
return wbcx.success;
|
||||
}
|
||||
|
||||
fn resolve_type_vars_in_fn(fcx: @fn_ctxt,
|
||||
decl: &ast::fn_decl,
|
||||
blk: ast::blk,
|
||||
self_info: Option<self_info>) -> bool {
|
||||
pub fn resolve_type_vars_in_fn(fcx: @fn_ctxt,
|
||||
decl: &ast::fn_decl,
|
||||
blk: ast::blk,
|
||||
self_info: Option<self_info>) -> bool {
|
||||
let wbcx = {fcx: fcx, mut success: true};
|
||||
let visit = mk_visitor();
|
||||
(visit.visit_block)(blk, wbcx, visit);
|
||||
|
Loading…
Reference in New Issue
Block a user