mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 18:53:39 +00:00
kill custom type inference defaults (these don't really work anyway)
This commit is contained in:
parent
7112d6584c
commit
047a8d0161
@ -22,7 +22,7 @@ use middle::free_region::RegionRelations;
|
||||
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 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
/// 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 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
-> &'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 @@ pub trait AstConv<'gcx, 'tcx> {
|
||||
/// 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 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
} 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 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||
} 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 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||
{
|
||||
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 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
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 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||
// `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::{self, InferCtxt, InferOk, RegionVariableOrigin};
|
||||
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 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, '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 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
// 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 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
// 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)
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user