librustc: De-@mut
the inference context
This commit is contained in:
parent
ff2d16e119
commit
a5f4a40f24
@ -1326,7 +1326,7 @@ impl<'a> LookupContext<'a> {
|
||||
ty::item_path_str(self.tcx(), did)));
|
||||
}
|
||||
|
||||
fn infcx(&self) -> @mut infer::InferCtxt {
|
||||
fn infcx(&self) -> @infer::InferCtxt {
|
||||
self.fcx.inh.infcx
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ pub struct SelfInfo {
|
||||
/// `bar()` will each have their own `FnCtxt`, but they will
|
||||
/// share the inherited fields.
|
||||
pub struct Inherited {
|
||||
infcx: @mut infer::InferCtxt,
|
||||
infcx: @infer::InferCtxt,
|
||||
locals: @mut HashMap<ast::NodeId, ty::t>,
|
||||
param_env: ty::ParameterEnvironment,
|
||||
|
||||
@ -1045,7 +1045,7 @@ impl AstConv for FnCtxt {
|
||||
}
|
||||
|
||||
impl FnCtxt {
|
||||
pub fn infcx(&self) -> @mut infer::InferCtxt {
|
||||
pub fn infcx(&self) -> @infer::InferCtxt {
|
||||
self.inh.infcx
|
||||
}
|
||||
|
||||
@ -1061,7 +1061,7 @@ impl FnCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
impl RegionScope for @mut infer::InferCtxt {
|
||||
impl RegionScope for @infer::InferCtxt {
|
||||
fn anon_regions(&self,
|
||||
span: Span,
|
||||
count: uint) -> Result<~[ty::Region], ()> {
|
||||
|
@ -70,7 +70,7 @@ pub struct LocationInfo {
|
||||
/// A vtable context includes an inference context, a crate context, and a
|
||||
/// callback function to call in case of type error.
|
||||
pub struct VtableContext<'a> {
|
||||
infcx: @mut infer::InferCtxt,
|
||||
infcx: @infer::InferCtxt,
|
||||
param_env: &'a ty::ParameterEnvironment,
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ pub struct UniversalQuantificationResult {
|
||||
type_param_defs: @~[ty::TypeParameterDef]
|
||||
}
|
||||
|
||||
pub fn get_base_type(inference_context: @mut InferCtxt,
|
||||
pub fn get_base_type(inference_context: @InferCtxt,
|
||||
span: Span,
|
||||
original_type: t)
|
||||
-> Option<t> {
|
||||
@ -118,7 +118,7 @@ pub fn type_is_defined_in_local_crate(original_type: t) -> bool {
|
||||
}
|
||||
|
||||
// Returns the def ID of the base type, if there is one.
|
||||
pub fn get_base_type_def_id(inference_context: @mut InferCtxt,
|
||||
pub fn get_base_type_def_id(inference_context: @InferCtxt,
|
||||
span: Span,
|
||||
original_type: t)
|
||||
-> Option<DefId> {
|
||||
@ -151,7 +151,7 @@ pub fn CoherenceChecker(crate_context: @CrateCtxt) -> CoherenceChecker {
|
||||
|
||||
pub struct CoherenceChecker {
|
||||
crate_context: @CrateCtxt,
|
||||
inference_context: @mut InferCtxt,
|
||||
inference_context: @InferCtxt,
|
||||
}
|
||||
|
||||
struct CoherenceCheckVisitor { cc: CoherenceChecker }
|
||||
|
@ -67,7 +67,7 @@ use syntax::opt_vec;
|
||||
use syntax::abi::AbiSet;
|
||||
|
||||
pub trait Combine {
|
||||
fn infcx(&self) -> @mut InferCtxt;
|
||||
fn infcx(&self) -> @InferCtxt;
|
||||
fn tag(&self) -> ~str;
|
||||
fn a_is_expected(&self) -> bool;
|
||||
fn trace(&self) -> TypeTrace;
|
||||
@ -328,7 +328,7 @@ pub trait Combine {
|
||||
}
|
||||
|
||||
pub struct CombineFields {
|
||||
infcx: @mut InferCtxt,
|
||||
infcx: @InferCtxt,
|
||||
a_is_expected: bool,
|
||||
trace: TypeTrace,
|
||||
}
|
||||
|
@ -77,33 +77,33 @@ use util::ppaux::bound_region_to_str;
|
||||
use util::ppaux::note_and_explain_region;
|
||||
|
||||
pub trait ErrorReporting {
|
||||
fn report_region_errors(@mut self,
|
||||
fn report_region_errors(@self,
|
||||
errors: &OptVec<RegionResolutionError>);
|
||||
|
||||
fn report_and_explain_type_error(@mut self,
|
||||
fn report_and_explain_type_error(@self,
|
||||
trace: TypeTrace,
|
||||
terr: &ty::type_err);
|
||||
|
||||
fn values_str(@mut self, values: &ValuePairs) -> Option<~str>;
|
||||
fn values_str(@self, values: &ValuePairs) -> Option<~str>;
|
||||
|
||||
fn expected_found_str<T:UserString+Resolvable>(
|
||||
@mut self,
|
||||
@self,
|
||||
exp_found: &ty::expected_found<T>)
|
||||
-> Option<~str>;
|
||||
|
||||
fn report_concrete_failure(@mut self,
|
||||
fn report_concrete_failure(@self,
|
||||
origin: SubregionOrigin,
|
||||
sub: Region,
|
||||
sup: Region);
|
||||
|
||||
fn report_sub_sup_conflict(@mut self,
|
||||
fn report_sub_sup_conflict(@self,
|
||||
var_origin: RegionVariableOrigin,
|
||||
sub_origin: SubregionOrigin,
|
||||
sub_region: Region,
|
||||
sup_origin: SubregionOrigin,
|
||||
sup_region: Region);
|
||||
|
||||
fn report_sup_sup_conflict(@mut self,
|
||||
fn report_sup_sup_conflict(@self,
|
||||
var_origin: RegionVariableOrigin,
|
||||
origin1: SubregionOrigin,
|
||||
region1: Region,
|
||||
@ -112,15 +112,15 @@ pub trait ErrorReporting {
|
||||
}
|
||||
|
||||
trait ErrorReportingHelpers {
|
||||
fn report_inference_failure(@mut self,
|
||||
fn report_inference_failure(@self,
|
||||
var_origin: RegionVariableOrigin);
|
||||
|
||||
fn note_region_origin(@mut self,
|
||||
fn note_region_origin(@self,
|
||||
origin: SubregionOrigin);
|
||||
}
|
||||
|
||||
impl ErrorReporting for InferCtxt {
|
||||
fn report_region_errors(@mut self,
|
||||
fn report_region_errors(@self,
|
||||
errors: &OptVec<RegionResolutionError>) {
|
||||
for error in errors.iter() {
|
||||
match *error {
|
||||
@ -147,7 +147,7 @@ impl ErrorReporting for InferCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
fn report_and_explain_type_error(@mut self,
|
||||
fn report_and_explain_type_error(@self,
|
||||
trace: TypeTrace,
|
||||
terr: &ty::type_err) {
|
||||
let tcx = self.tcx;
|
||||
@ -179,7 +179,7 @@ impl ErrorReporting for InferCtxt {
|
||||
ty::note_and_explain_type_err(self.tcx, terr);
|
||||
}
|
||||
|
||||
fn values_str(@mut self, values: &ValuePairs) -> Option<~str> {
|
||||
fn values_str(@self, values: &ValuePairs) -> Option<~str> {
|
||||
/*!
|
||||
* Returns a string of the form "expected `{}` but found `{}`",
|
||||
* or None if this is a derived error.
|
||||
@ -195,7 +195,7 @@ impl ErrorReporting for InferCtxt {
|
||||
}
|
||||
|
||||
fn expected_found_str<T:UserString+Resolvable>(
|
||||
@mut self,
|
||||
@self,
|
||||
exp_found: &ty::expected_found<T>)
|
||||
-> Option<~str>
|
||||
{
|
||||
@ -214,7 +214,7 @@ impl ErrorReporting for InferCtxt {
|
||||
found.user_string(self.tcx)))
|
||||
}
|
||||
|
||||
fn report_concrete_failure(@mut self,
|
||||
fn report_concrete_failure(@self,
|
||||
origin: SubregionOrigin,
|
||||
sub: Region,
|
||||
sup: Region) {
|
||||
@ -400,7 +400,7 @@ impl ErrorReporting for InferCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
fn report_sub_sup_conflict(@mut self,
|
||||
fn report_sub_sup_conflict(@self,
|
||||
var_origin: RegionVariableOrigin,
|
||||
sub_origin: SubregionOrigin,
|
||||
sub_region: Region,
|
||||
@ -425,7 +425,7 @@ impl ErrorReporting for InferCtxt {
|
||||
self.note_region_origin(sub_origin);
|
||||
}
|
||||
|
||||
fn report_sup_sup_conflict(@mut self,
|
||||
fn report_sup_sup_conflict(@self,
|
||||
var_origin: RegionVariableOrigin,
|
||||
origin1: SubregionOrigin,
|
||||
region1: Region,
|
||||
@ -452,7 +452,7 @@ impl ErrorReporting for InferCtxt {
|
||||
}
|
||||
|
||||
impl ErrorReportingHelpers for InferCtxt {
|
||||
fn report_inference_failure(@mut self,
|
||||
fn report_inference_failure(@self,
|
||||
var_origin: RegionVariableOrigin) {
|
||||
let var_description = match var_origin {
|
||||
infer::MiscVariable(_) => ~"",
|
||||
@ -484,8 +484,7 @@ impl ErrorReportingHelpers for InferCtxt {
|
||||
var_description));
|
||||
}
|
||||
|
||||
fn note_region_origin(@mut self,
|
||||
origin: SubregionOrigin) {
|
||||
fn note_region_origin(@self, origin: SubregionOrigin) {
|
||||
match origin {
|
||||
infer::Subtype(ref trace) => {
|
||||
let desc = match trace.origin {
|
||||
@ -612,12 +611,12 @@ impl ErrorReportingHelpers for InferCtxt {
|
||||
}
|
||||
|
||||
trait Resolvable {
|
||||
fn resolve(&self, infcx: @mut InferCtxt) -> Self;
|
||||
fn resolve(&self, infcx: @InferCtxt) -> Self;
|
||||
fn contains_error(&self) -> bool;
|
||||
}
|
||||
|
||||
impl Resolvable for ty::t {
|
||||
fn resolve(&self, infcx: @mut InferCtxt) -> ty::t {
|
||||
fn resolve(&self, infcx: @InferCtxt) -> ty::t {
|
||||
infcx.resolve_type_vars_if_possible(*self)
|
||||
}
|
||||
fn contains_error(&self) -> bool {
|
||||
@ -626,7 +625,7 @@ impl Resolvable for ty::t {
|
||||
}
|
||||
|
||||
impl Resolvable for @ty::TraitRef {
|
||||
fn resolve(&self, infcx: @mut InferCtxt) -> @ty::TraitRef {
|
||||
fn resolve(&self, infcx: @InferCtxt) -> @ty::TraitRef {
|
||||
@infcx.resolve_type_vars_in_trait_ref_if_possible(*self)
|
||||
}
|
||||
fn contains_error(&self) -> bool {
|
||||
|
@ -30,7 +30,7 @@ use util::ppaux::mt_to_str;
|
||||
pub struct Glb(CombineFields); // "greatest lower bound" (common subtype)
|
||||
|
||||
impl Combine for Glb {
|
||||
fn infcx(&self) -> @mut InferCtxt { self.infcx }
|
||||
fn infcx(&self) -> @InferCtxt { self.infcx }
|
||||
fn tag(&self) -> ~str { ~"glb" }
|
||||
fn a_is_expected(&self) -> bool { self.a_is_expected }
|
||||
fn trace(&self) -> TypeTrace { self.trace }
|
||||
|
@ -36,7 +36,7 @@ impl Lub {
|
||||
}
|
||||
|
||||
impl Combine for Lub {
|
||||
fn infcx(&self) -> @mut InferCtxt { self.infcx }
|
||||
fn infcx(&self) -> @InferCtxt { self.infcx }
|
||||
fn tag(&self) -> ~str { ~"lub" }
|
||||
fn a_is_expected(&self) -> bool { self.a_is_expected }
|
||||
fn trace(&self) -> TypeTrace { self.trace }
|
||||
|
@ -258,8 +258,8 @@ fn new_ValsAndBindings<V:Clone,T:Clone>() -> ValsAndBindings<V, T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_infer_ctxt(tcx: ty::ctxt) -> @mut InferCtxt {
|
||||
@mut InferCtxt {
|
||||
pub fn new_infer_ctxt(tcx: ty::ctxt) -> @InferCtxt {
|
||||
@InferCtxt {
|
||||
tcx: tcx,
|
||||
|
||||
ty_var_bindings: RefCell::new(new_ValsAndBindings()),
|
||||
@ -275,7 +275,7 @@ pub fn new_infer_ctxt(tcx: ty::ctxt) -> @mut InferCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn common_supertype(cx: @mut InferCtxt,
|
||||
pub fn common_supertype(cx: @InferCtxt,
|
||||
origin: TypeOrigin,
|
||||
a_is_expected: bool,
|
||||
a: ty::t,
|
||||
@ -303,7 +303,7 @@ pub fn common_supertype(cx: @mut InferCtxt,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mk_subty(cx: @mut InferCtxt,
|
||||
pub fn mk_subty(cx: @InferCtxt,
|
||||
a_is_expected: bool,
|
||||
origin: TypeOrigin,
|
||||
a: ty::t,
|
||||
@ -321,7 +321,7 @@ pub fn mk_subty(cx: @mut InferCtxt,
|
||||
}).to_ures()
|
||||
}
|
||||
|
||||
pub fn can_mk_subty(cx: @mut InferCtxt, a: ty::t, b: ty::t) -> ures {
|
||||
pub fn can_mk_subty(cx: @InferCtxt, a: ty::t, b: ty::t) -> ures {
|
||||
debug!("can_mk_subty({} <: {})", a.inf_str(cx), b.inf_str(cx));
|
||||
indent(|| {
|
||||
cx.probe(|| {
|
||||
@ -334,7 +334,7 @@ pub fn can_mk_subty(cx: @mut InferCtxt, a: ty::t, b: ty::t) -> ures {
|
||||
}).to_ures()
|
||||
}
|
||||
|
||||
pub fn mk_subr(cx: @mut InferCtxt,
|
||||
pub fn mk_subr(cx: @InferCtxt,
|
||||
_a_is_expected: bool,
|
||||
origin: SubregionOrigin,
|
||||
a: ty::Region,
|
||||
@ -345,7 +345,7 @@ pub fn mk_subr(cx: @mut InferCtxt,
|
||||
cx.region_vars.commit();
|
||||
}
|
||||
|
||||
pub fn mk_eqty(cx: @mut InferCtxt,
|
||||
pub fn mk_eqty(cx: @InferCtxt,
|
||||
a_is_expected: bool,
|
||||
origin: TypeOrigin,
|
||||
a: ty::t,
|
||||
@ -364,7 +364,7 @@ pub fn mk_eqty(cx: @mut InferCtxt,
|
||||
}).to_ures()
|
||||
}
|
||||
|
||||
pub fn mk_sub_trait_refs(cx: @mut InferCtxt,
|
||||
pub fn mk_sub_trait_refs(cx: @InferCtxt,
|
||||
a_is_expected: bool,
|
||||
origin: TypeOrigin,
|
||||
a: @ty::TraitRef,
|
||||
@ -395,7 +395,7 @@ fn expected_found<T>(a_is_expected: bool,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mk_coercety(cx: @mut InferCtxt,
|
||||
pub fn mk_coercety(cx: @InferCtxt,
|
||||
a_is_expected: bool,
|
||||
origin: TypeOrigin,
|
||||
a: ty::t,
|
||||
@ -413,7 +413,7 @@ pub fn mk_coercety(cx: @mut InferCtxt,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn can_mk_coercety(cx: @mut InferCtxt, a: ty::t, b: ty::t) -> ures {
|
||||
pub fn can_mk_coercety(cx: @InferCtxt, a: ty::t, b: ty::t) -> ures {
|
||||
debug!("can_mk_coercety({} -> {})", a.inf_str(cx), b.inf_str(cx));
|
||||
indent(|| {
|
||||
cx.probe(|| {
|
||||
@ -427,7 +427,7 @@ pub fn can_mk_coercety(cx: @mut InferCtxt, a: ty::t, b: ty::t) -> ures {
|
||||
}
|
||||
|
||||
// See comment on the type `resolve_state` below
|
||||
pub fn resolve_type(cx: @mut InferCtxt,
|
||||
pub fn resolve_type(cx: @InferCtxt,
|
||||
a: ty::t,
|
||||
modes: uint)
|
||||
-> fres<ty::t> {
|
||||
@ -435,7 +435,7 @@ pub fn resolve_type(cx: @mut InferCtxt,
|
||||
resolver.resolve_type_chk(a)
|
||||
}
|
||||
|
||||
pub fn resolve_region(cx: @mut InferCtxt, r: ty::Region, modes: uint)
|
||||
pub fn resolve_region(cx: @InferCtxt, r: ty::Region, modes: uint)
|
||||
-> fres<ty::Region> {
|
||||
let mut resolver = resolver(cx, modes);
|
||||
resolver.resolve_region_chk(r)
|
||||
@ -502,20 +502,18 @@ struct Snapshot {
|
||||
}
|
||||
|
||||
impl InferCtxt {
|
||||
pub fn combine_fields(@mut self,
|
||||
a_is_expected: bool,
|
||||
trace: TypeTrace)
|
||||
pub fn combine_fields(@self, a_is_expected: bool, trace: TypeTrace)
|
||||
-> CombineFields {
|
||||
CombineFields {infcx: self,
|
||||
a_is_expected: a_is_expected,
|
||||
trace: trace}
|
||||
}
|
||||
|
||||
pub fn sub(@mut self, a_is_expected: bool, trace: TypeTrace) -> Sub {
|
||||
pub fn sub(@self, a_is_expected: bool, trace: TypeTrace) -> Sub {
|
||||
Sub(self.combine_fields(a_is_expected, trace))
|
||||
}
|
||||
|
||||
pub fn lub(@mut self, a_is_expected: bool, trace: TypeTrace) -> Lub {
|
||||
pub fn lub(@self, a_is_expected: bool, trace: TypeTrace) -> Lub {
|
||||
Lub(self.combine_fields(a_is_expected, trace))
|
||||
}
|
||||
|
||||
@ -523,7 +521,7 @@ impl InferCtxt {
|
||||
self.region_vars.in_snapshot()
|
||||
}
|
||||
|
||||
pub fn start_snapshot(&mut self) -> Snapshot {
|
||||
pub fn start_snapshot(&self) -> Snapshot {
|
||||
let ty_var_bindings = self.ty_var_bindings.borrow();
|
||||
let int_var_bindings = self.int_var_bindings.borrow();
|
||||
let float_var_bindings = self.float_var_bindings.borrow();
|
||||
@ -535,7 +533,7 @@ impl InferCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rollback_to(&mut self, snapshot: &Snapshot) {
|
||||
pub fn rollback_to(&self, snapshot: &Snapshot) {
|
||||
debug!("rollback!");
|
||||
let mut ty_var_bindings = self.ty_var_bindings.borrow_mut();
|
||||
let mut int_var_bindings = self.int_var_bindings.borrow_mut();
|
||||
@ -549,7 +547,7 @@ impl InferCtxt {
|
||||
}
|
||||
|
||||
/// Execute `f` and commit the bindings if successful
|
||||
pub fn commit<T,E>(@mut self, f: || -> Result<T,E>) -> Result<T,E> {
|
||||
pub fn commit<T,E>(@self, f: || -> Result<T,E>) -> Result<T,E> {
|
||||
assert!(!self.in_snapshot());
|
||||
|
||||
debug!("commit()");
|
||||
@ -566,7 +564,7 @@ impl InferCtxt {
|
||||
}
|
||||
|
||||
/// Execute `f`, unroll bindings on failure
|
||||
pub fn try<T,E>(@mut self, f: || -> Result<T,E>) -> Result<T,E> {
|
||||
pub fn try<T,E>(@self, f: || -> Result<T,E>) -> Result<T,E> {
|
||||
debug!("try()");
|
||||
let snapshot = self.start_snapshot();
|
||||
let r = f();
|
||||
@ -581,7 +579,7 @@ impl InferCtxt {
|
||||
}
|
||||
|
||||
/// Execute `f` then unroll any bindings it creates
|
||||
pub fn probe<T,E>(@mut self, f: || -> Result<T,E>) -> Result<T,E> {
|
||||
pub fn probe<T,E>(@self, f: || -> Result<T,E>) -> Result<T,E> {
|
||||
debug!("probe()");
|
||||
indent(|| {
|
||||
let snapshot = self.start_snapshot();
|
||||
@ -603,7 +601,7 @@ fn next_simple_var<V:Clone,T:Clone>(counter: &mut uint,
|
||||
}
|
||||
|
||||
impl InferCtxt {
|
||||
pub fn next_ty_var_id(&mut self) -> TyVid {
|
||||
pub fn next_ty_var_id(&self) -> TyVid {
|
||||
let id = self.ty_var_counter.get();
|
||||
self.ty_var_counter.set(id + 1);
|
||||
{
|
||||
@ -614,15 +612,15 @@ impl InferCtxt {
|
||||
return TyVid(id);
|
||||
}
|
||||
|
||||
pub fn next_ty_var(&mut self) -> ty::t {
|
||||
pub fn next_ty_var(&self) -> ty::t {
|
||||
ty::mk_var(self.tcx, self.next_ty_var_id())
|
||||
}
|
||||
|
||||
pub fn next_ty_vars(&mut self, n: uint) -> ~[ty::t] {
|
||||
pub fn next_ty_vars(&self, n: uint) -> ~[ty::t] {
|
||||
vec::from_fn(n, |_i| self.next_ty_var())
|
||||
}
|
||||
|
||||
pub fn next_int_var_id(&mut self) -> IntVid {
|
||||
pub fn next_int_var_id(&self) -> IntVid {
|
||||
let mut int_var_counter = self.int_var_counter.get();
|
||||
let mut int_var_bindings = self.int_var_bindings.borrow_mut();
|
||||
let result = IntVid(next_simple_var(&mut int_var_counter,
|
||||
@ -631,11 +629,11 @@ impl InferCtxt {
|
||||
result
|
||||
}
|
||||
|
||||
pub fn next_int_var(&mut self) -> ty::t {
|
||||
pub fn next_int_var(&self) -> ty::t {
|
||||
ty::mk_int_var(self.tcx, self.next_int_var_id())
|
||||
}
|
||||
|
||||
pub fn next_float_var_id(&mut self) -> FloatVid {
|
||||
pub fn next_float_var_id(&self) -> FloatVid {
|
||||
let mut float_var_counter = self.float_var_counter.get();
|
||||
let mut float_var_bindings = self.float_var_bindings.borrow_mut();
|
||||
let result = FloatVid(next_simple_var(&mut float_var_counter,
|
||||
@ -644,53 +642,53 @@ impl InferCtxt {
|
||||
result
|
||||
}
|
||||
|
||||
pub fn next_float_var(&mut self) -> ty::t {
|
||||
pub fn next_float_var(&self) -> ty::t {
|
||||
ty::mk_float_var(self.tcx, self.next_float_var_id())
|
||||
}
|
||||
|
||||
pub fn next_region_var(&mut self, origin: RegionVariableOrigin) -> ty::Region {
|
||||
pub fn next_region_var(&self, origin: RegionVariableOrigin) -> ty::Region {
|
||||
ty::ReInfer(ty::ReVar(self.region_vars.new_region_var(origin)))
|
||||
}
|
||||
|
||||
pub fn next_region_vars(&mut self,
|
||||
pub fn next_region_vars(&self,
|
||||
origin: RegionVariableOrigin,
|
||||
count: uint)
|
||||
-> ~[ty::Region] {
|
||||
vec::from_fn(count, |_| self.next_region_var(origin))
|
||||
}
|
||||
|
||||
pub fn fresh_bound_region(&mut self, binder_id: ast::NodeId) -> ty::Region {
|
||||
pub fn fresh_bound_region(&self, binder_id: ast::NodeId) -> ty::Region {
|
||||
self.region_vars.new_bound(binder_id)
|
||||
}
|
||||
|
||||
pub fn resolve_regions(@mut self) {
|
||||
pub fn resolve_regions(@self) {
|
||||
let errors = self.region_vars.resolve_regions();
|
||||
self.report_region_errors(&errors); // see error_reporting.rs
|
||||
}
|
||||
|
||||
pub fn ty_to_str(@mut self, t: ty::t) -> ~str {
|
||||
pub fn ty_to_str(@self, t: ty::t) -> ~str {
|
||||
ty_to_str(self.tcx,
|
||||
self.resolve_type_vars_if_possible(t))
|
||||
}
|
||||
|
||||
pub fn tys_to_str(@mut self, ts: &[ty::t]) -> ~str {
|
||||
pub fn tys_to_str(@self, ts: &[ty::t]) -> ~str {
|
||||
let tstrs = ts.map(|t| self.ty_to_str(*t));
|
||||
format!("({})", tstrs.connect(", "))
|
||||
}
|
||||
|
||||
pub fn trait_ref_to_str(@mut self, t: &ty::TraitRef) -> ~str {
|
||||
pub fn trait_ref_to_str(@self, t: &ty::TraitRef) -> ~str {
|
||||
let t = self.resolve_type_vars_in_trait_ref_if_possible(t);
|
||||
trait_ref_to_str(self.tcx, &t)
|
||||
}
|
||||
|
||||
pub fn resolve_type_vars_if_possible(@mut self, typ: ty::t) -> ty::t {
|
||||
pub fn resolve_type_vars_if_possible(@self, typ: ty::t) -> ty::t {
|
||||
match resolve_type(self, typ, resolve_nested_tvar | resolve_ivar) {
|
||||
result::Ok(new_type) => new_type,
|
||||
result::Err(_) => typ
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resolve_type_vars_in_trait_ref_if_possible(@mut self,
|
||||
pub fn resolve_type_vars_in_trait_ref_if_possible(@self,
|
||||
trait_ref:
|
||||
&ty::TraitRef)
|
||||
-> ty::TraitRef {
|
||||
@ -730,7 +728,7 @@ impl InferCtxt {
|
||||
// in this case. The typechecker should only ever report type errors involving mismatched
|
||||
// types using one of these four methods, and should not call span_err directly for such
|
||||
// errors.
|
||||
pub fn type_error_message_str(@mut self,
|
||||
pub fn type_error_message_str(@self,
|
||||
sp: Span,
|
||||
mk_msg: |Option<~str>, ~str| -> ~str,
|
||||
actual_ty: ~str,
|
||||
@ -738,7 +736,7 @@ impl InferCtxt {
|
||||
self.type_error_message_str_with_expected(sp, mk_msg, None, actual_ty, err)
|
||||
}
|
||||
|
||||
pub fn type_error_message_str_with_expected(@mut self,
|
||||
pub fn type_error_message_str_with_expected(@self,
|
||||
sp: Span,
|
||||
mk_msg: |Option<~str>,
|
||||
~str|
|
||||
@ -769,7 +767,7 @@ impl InferCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_error_message(@mut self,
|
||||
pub fn type_error_message(@self,
|
||||
sp: Span,
|
||||
mk_msg: |~str| -> ~str,
|
||||
actual_ty: ty::t,
|
||||
@ -784,7 +782,7 @@ impl InferCtxt {
|
||||
self.type_error_message_str(sp, |_e, a| { mk_msg(a) }, self.ty_to_str(actual_ty), err);
|
||||
}
|
||||
|
||||
pub fn report_mismatched_types(@mut self,
|
||||
pub fn report_mismatched_types(@self,
|
||||
sp: Span,
|
||||
e: ty::t,
|
||||
a: ty::t,
|
||||
@ -805,7 +803,7 @@ impl InferCtxt {
|
||||
self.type_error_message(sp, mk_msg, a, Some(err));
|
||||
}
|
||||
|
||||
pub fn replace_bound_regions_with_fresh_regions(&mut self,
|
||||
pub fn replace_bound_regions_with_fresh_regions(&self,
|
||||
trace: TypeTrace,
|
||||
fsig: &ty::FnSig)
|
||||
-> (ty::FnSig,
|
||||
|
@ -80,14 +80,14 @@ pub static resolve_and_force_all_but_regions: uint =
|
||||
(resolve_all | force_all) & not_regions;
|
||||
|
||||
pub struct ResolveState {
|
||||
infcx: @mut InferCtxt,
|
||||
infcx: @InferCtxt,
|
||||
modes: uint,
|
||||
err: Option<fixup_err>,
|
||||
v_seen: ~[TyVid],
|
||||
type_depth: uint
|
||||
}
|
||||
|
||||
pub fn resolver(infcx: @mut InferCtxt, modes: uint) -> ResolveState {
|
||||
pub fn resolver(infcx: @InferCtxt, modes: uint) -> ResolveState {
|
||||
ResolveState {
|
||||
infcx: infcx,
|
||||
modes: modes,
|
||||
|
@ -29,7 +29,7 @@ use syntax::ast::{Onceness, purity};
|
||||
pub struct Sub(CombineFields); // "subtype", "subregion" etc
|
||||
|
||||
impl Combine for Sub {
|
||||
fn infcx(&self) -> @mut InferCtxt { self.infcx }
|
||||
fn infcx(&self) -> @InferCtxt { self.infcx }
|
||||
fn tag(&self) -> ~str { ~"sub" }
|
||||
fn a_is_expected(&self) -> bool { self.a_is_expected }
|
||||
fn trace(&self) -> TypeTrace { self.trace }
|
||||
|
@ -37,25 +37,24 @@ pub struct Node<V, T> {
|
||||
}
|
||||
|
||||
pub trait UnifyVid<T> {
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v mut InferCtxt)
|
||||
-> &'v mut RefCell<ValsAndBindings<Self,
|
||||
T>>;
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v InferCtxt)
|
||||
-> &'v RefCell<ValsAndBindings<Self, T>>;
|
||||
}
|
||||
|
||||
pub trait UnifyInferCtxtMethods {
|
||||
fn get<T:Clone,
|
||||
V:Clone + Eq + Vid + UnifyVid<T>>(
|
||||
&mut self,
|
||||
&self,
|
||||
vid: V)
|
||||
-> Node<V, T>;
|
||||
fn set<T:Clone + InferStr,
|
||||
V:Clone + Vid + ToStr + UnifyVid<T>>(
|
||||
&mut self,
|
||||
&self,
|
||||
vid: V,
|
||||
new_v: VarValue<V, T>);
|
||||
fn unify<T:Clone + InferStr,
|
||||
V:Clone + Vid + ToStr + UnifyVid<T>>(
|
||||
&mut self,
|
||||
&self,
|
||||
node_a: &Node<V, T>,
|
||||
node_b: &Node<V, T>)
|
||||
-> (V, uint);
|
||||
@ -64,7 +63,7 @@ pub trait UnifyInferCtxtMethods {
|
||||
impl UnifyInferCtxtMethods for InferCtxt {
|
||||
fn get<T:Clone,
|
||||
V:Clone + Eq + Vid + UnifyVid<T>>(
|
||||
&mut self,
|
||||
&self,
|
||||
vid: V)
|
||||
-> Node<V, T> {
|
||||
/*!
|
||||
@ -111,7 +110,7 @@ impl UnifyInferCtxtMethods for InferCtxt {
|
||||
|
||||
fn set<T:Clone + InferStr,
|
||||
V:Clone + Vid + ToStr + UnifyVid<T>>(
|
||||
&mut self,
|
||||
&self,
|
||||
vid: V,
|
||||
new_v: VarValue<V, T>) {
|
||||
/*!
|
||||
@ -131,7 +130,7 @@ impl UnifyInferCtxtMethods for InferCtxt {
|
||||
|
||||
fn unify<T:Clone + InferStr,
|
||||
V:Clone + Vid + ToStr + UnifyVid<T>>(
|
||||
&mut self,
|
||||
&self,
|
||||
node_a: &Node<V, T>,
|
||||
node_b: &Node<V, T>)
|
||||
-> (V, uint) {
|
||||
@ -186,14 +185,14 @@ pub fn mk_err<T:SimplyUnifiable>(a_is_expected: bool,
|
||||
pub trait InferCtxtMethods {
|
||||
fn simple_vars<T:Clone + Eq + InferStr + SimplyUnifiable,
|
||||
V:Clone + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
|
||||
&mut self,
|
||||
&self,
|
||||
a_is_expected: bool,
|
||||
a_id: V,
|
||||
b_id: V)
|
||||
-> ures;
|
||||
fn simple_var_t<T:Clone + Eq + InferStr + SimplyUnifiable,
|
||||
V:Clone + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
|
||||
&mut self,
|
||||
&self,
|
||||
a_is_expected: bool,
|
||||
a_id: V,
|
||||
b: T)
|
||||
@ -203,7 +202,7 @@ pub trait InferCtxtMethods {
|
||||
impl InferCtxtMethods for InferCtxt {
|
||||
fn simple_vars<T:Clone + Eq + InferStr + SimplyUnifiable,
|
||||
V:Clone + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
|
||||
&mut self,
|
||||
&self,
|
||||
a_is_expected: bool,
|
||||
a_id: V,
|
||||
b_id: V)
|
||||
@ -243,7 +242,7 @@ impl InferCtxtMethods for InferCtxt {
|
||||
|
||||
fn simple_var_t<T:Clone + Eq + InferStr + SimplyUnifiable,
|
||||
V:Clone + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
|
||||
&mut self,
|
||||
&self,
|
||||
a_is_expected: bool,
|
||||
a_id: V,
|
||||
b: T)
|
||||
@ -278,16 +277,16 @@ impl InferCtxtMethods for InferCtxt {
|
||||
// ______________________________________________________________________
|
||||
|
||||
impl UnifyVid<Bounds<ty::t>> for ty::TyVid {
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v mut InferCtxt)
|
||||
-> &'v mut RefCell<ValsAndBindings<ty::TyVid, Bounds<ty::t>>> {
|
||||
return &mut infcx.ty_var_bindings;
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v InferCtxt)
|
||||
-> &'v RefCell<ValsAndBindings<ty::TyVid, Bounds<ty::t>>> {
|
||||
return &infcx.ty_var_bindings;
|
||||
}
|
||||
}
|
||||
|
||||
impl UnifyVid<Option<IntVarValue>> for ty::IntVid {
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v mut InferCtxt)
|
||||
-> &'v mut RefCell<ValsAndBindings<ty::IntVid, Option<IntVarValue>>> {
|
||||
return &mut infcx.int_var_bindings;
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v InferCtxt)
|
||||
-> &'v RefCell<ValsAndBindings<ty::IntVid, Option<IntVarValue>>> {
|
||||
return &infcx.int_var_bindings;
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,10 +297,10 @@ impl SimplyUnifiable for IntVarValue {
|
||||
}
|
||||
|
||||
impl UnifyVid<Option<ast::float_ty>> for ty::FloatVid {
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v mut InferCtxt)
|
||||
-> &'v mut RefCell<ValsAndBindings<ty::FloatVid,
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v InferCtxt)
|
||||
-> &'v RefCell<ValsAndBindings<ty::FloatVid,
|
||||
Option<ast::float_ty>>> {
|
||||
return &mut infcx.float_var_bindings;
|
||||
return &infcx.float_var_bindings;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ pub fn no_params(t: ty::t) -> ty::ty_param_bounds_and_ty {
|
||||
}
|
||||
|
||||
pub fn require_same_types(tcx: ty::ctxt,
|
||||
maybe_infcx: Option<@mut infer::InferCtxt>,
|
||||
maybe_infcx: Option<@infer::InferCtxt>,
|
||||
t1_is_expected: bool,
|
||||
span: Span,
|
||||
t1: ty::t,
|
||||
|
Loading…
x
Reference in New Issue
Block a user