提交 047a8d01 编写于 作者: N Niko Matsakis 提交者: Sean Griffin

kill custom type inference defaults (these don't really work anyway)

上级 7112d658
......@@ -22,7 +22,7 @@
use middle::region;
use middle::lang_items;
use mir::tcx::PlaceTy;
use ty::subst::{Kind, Subst, Substs};
use ty::subst::Substs;
use ty::{TyVid, IntVid, FloatVid};
use ty::{self, Ty, TyCtxt};
use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
......@@ -1093,26 +1093,13 @@ pub fn region_var_for_def(&self,
/// as the substitutions for the default, `(T, U)`.
pub fn type_var_for_def(&self,
span: Span,
def: &ty::TypeParameterDef,
substs: &[Kind<'tcx>])
def: &ty::TypeParameterDef)
-> Ty<'tcx> {
let default = if def.has_default {
let default = self.tcx.type_of(def.def_id);
Some(type_variable::Default {
ty: default.subst_spanned(self.tcx, substs, Some(span)),
origin_span: span,
def_id: def.def_id
})
} else {
None
};
let ty_var_id = self.type_variables
.borrow_mut()
.new_var(false,
TypeVariableOrigin::TypeParameterDefinition(span, def.name),
default);
None);
self.tcx.mk_var(ty_var_id)
}
......@@ -1125,8 +1112,8 @@ pub fn fresh_substs_for_item(&self,
-> &'tcx Substs<'tcx> {
Substs::for_item(self.tcx, def_id, |def, _| {
self.region_var_for_def(span, def)
}, |def, substs| {
self.type_var_for_def(span, def, substs)
}, |def, _| {
self.type_var_for_def(span, def)
})
}
......
......@@ -51,7 +51,6 @@ fn re_infer(&self, span: Span, _def: Option<&ty::RegionParameterDef>)
/// Same as ty_infer, but with a known type parameter definition.
fn ty_infer_for_def(&self,
_def: &ty::TypeParameterDef,
_substs: &[Kind<'tcx>],
span: Span) -> Ty<'tcx> {
self.ty_infer(span)
}
......@@ -261,7 +260,7 @@ fn create_substs_for_ast_path(&self,
} else if infer_types {
// No type parameters were provided, we can infer all.
let ty_var = if !default_needs_object_self(def) {
self.ty_infer_for_def(def, substs, span)
self.ty_infer_for_def(def, span)
} else {
self.ty_infer(span)
};
......
......@@ -325,7 +325,7 @@ fn instantiate_method_substs(&mut self,
} else {
self.region_var_for_def(self.span, def)
}
}, |def, cur_substs| {
}, |def, _cur_substs| {
let i = def.index as usize;
if i < parent_substs.len() {
parent_substs.type_at(i)
......@@ -336,7 +336,7 @@ fn instantiate_method_substs(&mut self,
{
self.to_ty(ast_ty)
} else {
self.type_var_for_def(self.span, def, cur_substs)
self.type_var_for_def(self.span, def)
}
})
}
......
......@@ -249,13 +249,13 @@ pub fn lookup_method_in_trait(&self,
let substs = Substs::for_item(self.tcx,
trait_def_id,
|def, _| self.region_var_for_def(span, def),
|def, substs| {
|def, _substs| {
if def.index == 0 {
self_ty
} else if let Some(ref input_types) = opt_input_types {
input_types[def.index as usize - 1]
} else {
self.type_var_for_def(span, def, substs)
self.type_var_for_def(span, def)
}
});
......
......@@ -1304,12 +1304,12 @@ fn xform_method_sig(&self,
// `impl_self_ty()` for an explanation.
self.tcx.types.re_erased
}
}, |def, cur_substs| {
}, |def, _cur_substs| {
let i = def.index as usize;
if i < substs.len() {
substs.type_at(i)
} else {
self.type_var_for_def(self.span, def, cur_substs)
self.type_var_for_def(self.span, def)
}
});
xform_fn_sig.subst(self.tcx, substs)
......
......@@ -93,7 +93,7 @@
use rustc::infer::anon_types::AnonTypeDecl;
use rustc::infer::type_variable::{TypeVariableOrigin};
use rustc::middle::region;
use rustc::ty::subst::{Kind, Subst, Substs};
use rustc::ty::subst::{Subst, Substs};
use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode};
use rustc::ty::{self, Ty, TyCtxt, Visibility, ToPredicate};
use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
......@@ -1692,9 +1692,8 @@ fn ty_infer(&self, span: Span) -> Ty<'tcx> {
fn ty_infer_for_def(&self,
ty_param_def: &ty::TypeParameterDef,
substs: &[Kind<'tcx>],
span: Span) -> Ty<'tcx> {
self.type_var_for_def(span, ty_param_def, substs)
self.type_var_for_def(span, ty_param_def)
}
fn projected_ty_from_poly_trait_ref(&self,
......@@ -4793,7 +4792,7 @@ pub fn instantiate_value_path(&self,
// Handle Self first, so we can adjust the index to match the AST.
if has_self && i == 0 {
return opt_self_ty.unwrap_or_else(|| {
self.type_var_for_def(span, def, substs)
self.type_var_for_def(span, def)
});
}
i -= has_self as usize;
......@@ -4826,7 +4825,7 @@ pub fn instantiate_value_path(&self,
// This can also be reached in some error cases:
// We prefer to use inference variables instead of
// TyError to let type inference recover somewhat.
self.type_var_for_def(span, def, substs)
self.type_var_for_def(span, def)
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册