Auto merge of #30054 - Ms2ger:TypeOrigin, r=eddyb

This commit is contained in:
bors 2015-11-26 13:07:18 +00:00
commit da0444d5d4
16 changed files with 83 additions and 82 deletions

View File

@ -78,7 +78,7 @@ use rustc_front::print::pprust;
use middle::def;
use middle::def_id::DefId;
use middle::infer;
use middle::infer::{self, TypeOrigin};
use middle::region;
use middle::subst;
use middle::ty::{self, Ty, HasTypeFlags};
@ -474,7 +474,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
self.check_and_note_conflicting_crates(terr, trace.origin.span());
match trace.origin {
infer::MatchExpressionArm(_, arm_span, source) => match source {
TypeOrigin::MatchExpressionArm(_, arm_span, source) => match source {
hir::MatchSource::IfLetDesugar{..} =>
self.tcx.sess.span_note(arm_span, "`if let` arm with an incompatible type"),
_ => self.tcx.sess.span_note(arm_span, "match arm with an incompatible type"),
@ -1602,38 +1602,38 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
}
infer::Subtype(ref trace) => {
let desc = match trace.origin {
infer::Misc(_) => {
TypeOrigin::Misc(_) => {
"types are compatible"
}
infer::MethodCompatCheck(_) => {
TypeOrigin::MethodCompatCheck(_) => {
"method type is compatible with trait"
}
infer::ExprAssignable(_) => {
TypeOrigin::ExprAssignable(_) => {
"expression is assignable"
}
infer::RelateTraitRefs(_) => {
TypeOrigin::RelateTraitRefs(_) => {
"traits are compatible"
}
infer::RelateSelfType(_) => {
TypeOrigin::RelateSelfType(_) => {
"self type matches impl self type"
}
infer::RelateOutputImplTypes(_) => {
TypeOrigin::RelateOutputImplTypes(_) => {
"trait type parameters matches those \
specified on the impl"
}
infer::MatchExpressionArm(_, _, _) => {
TypeOrigin::MatchExpressionArm(_, _, _) => {
"match arms have compatible types"
}
infer::IfExpression(_) => {
TypeOrigin::IfExpression(_) => {
"if and else have compatible types"
}
infer::IfExpressionWithNoElse(_) => {
TypeOrigin::IfExpressionWithNoElse(_) => {
"if may be missing an else clause"
}
infer::RangeExpression(_) => {
TypeOrigin::RangeExpression(_) => {
"start and end of range have compatible types"
}
infer::EquatePredicate(_) => {
TypeOrigin::EquatePredicate(_) => {
"equality where clause is satisfied"
}
};

View File

@ -13,7 +13,6 @@
pub use self::LateBoundRegionConversionTime::*;
pub use self::RegionVariableOrigin::*;
pub use self::SubregionOrigin::*;
pub use self::TypeOrigin::*;
pub use self::ValuePairs::*;
pub use middle::ty::IntVarValue;
pub use self::freshen::TypeFreshener;
@ -440,7 +439,7 @@ pub fn can_mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
debug!("can_mk_subty({:?} <: {:?})", a, b);
cx.probe(|_| {
let trace = TypeTrace {
origin: Misc(codemap::DUMMY_SP),
origin: TypeOrigin::Misc(codemap::DUMMY_SP),
values: Types(expected_found(true, a, b))
};
cx.sub(true, trace).relate(&a, &b).map(|_| ())
@ -950,7 +949,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
self.commit_if_ok(|snapshot| {
let (ty::EquatePredicate(a, b), skol_map) =
self.skolemize_late_bound_regions(predicate, snapshot);
let origin = EquatePredicate(span);
let origin = TypeOrigin::EquatePredicate(span);
let () = try!(mk_eqty(self, false, origin, a, b));
self.leak_check(&skol_map, snapshot)
})
@ -1328,7 +1327,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
actual: Ty<'tcx>,
err: &TypeError<'tcx>) {
let trace = TypeTrace {
origin: Misc(span),
origin: TypeOrigin::Misc(span),
values: Types(ExpectedFound {
expected: expected,
found: actual
@ -1342,7 +1341,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
expected: type_variable::Default<'tcx>,
actual: type_variable::Default<'tcx>) {
let trace = TypeTrace {
origin: Misc(span),
origin: TypeOrigin::Misc(span),
values: Types(ExpectedFound {
expected: expected.ty,
found: actual.ty
@ -1393,8 +1392,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
// generic so we don't have to do anything quite this
// terrible.
let e = self.tcx.types.err;
let trace = TypeTrace { origin: Misc(codemap::DUMMY_SP),
values: Types(expected_found(true, e, e)) };
let trace = TypeTrace {
origin: TypeOrigin::Misc(codemap::DUMMY_SP),
values: Types(expected_found(true, e, e))
};
self.equate(true, trace).relate(a, b)
}).map(|_| ())
}
@ -1525,7 +1526,7 @@ impl<'tcx> TypeTrace<'tcx> {
pub fn dummy(tcx: &ty::ctxt<'tcx>) -> TypeTrace<'tcx> {
TypeTrace {
origin: Misc(codemap::DUMMY_SP),
origin: TypeOrigin::Misc(codemap::DUMMY_SP),
values: Types(ExpectedFound {
expected: tcx.types.err,
found: tcx.types.err,
@ -1543,17 +1544,17 @@ impl<'tcx> fmt::Debug for TypeTrace<'tcx> {
impl TypeOrigin {
pub fn span(&self) -> Span {
match *self {
MethodCompatCheck(span) => span,
ExprAssignable(span) => span,
Misc(span) => span,
RelateTraitRefs(span) => span,
RelateSelfType(span) => span,
RelateOutputImplTypes(span) => span,
MatchExpressionArm(match_span, _, _) => match_span,
IfExpression(span) => span,
IfExpressionWithNoElse(span) => span,
RangeExpression(span) => span,
EquatePredicate(span) => span,
TypeOrigin::MethodCompatCheck(span) => span,
TypeOrigin::ExprAssignable(span) => span,
TypeOrigin::Misc(span) => span,
TypeOrigin::RelateTraitRefs(span) => span,
TypeOrigin::RelateSelfType(span) => span,
TypeOrigin::RelateOutputImplTypes(span) => span,
TypeOrigin::MatchExpressionArm(match_span, _, _) => match_span,
TypeOrigin::IfExpression(span) => span,
TypeOrigin::IfExpressionWithNoElse(span) => span,
TypeOrigin::RangeExpression(span) => span,
TypeOrigin::EquatePredicate(span) => span,
}
}
}

View File

@ -21,7 +21,7 @@ use metadata::cstore::LOCAL_CRATE;
use middle::def_id::DefId;
use middle::subst::{Subst, Substs, TypeSpace};
use middle::ty::{self, Ty};
use middle::infer::{self, InferCtxt};
use middle::infer::{self, InferCtxt, TypeOrigin};
use syntax::codemap::{DUMMY_SP, Span};
#[derive(Copy, Clone)]
@ -70,7 +70,7 @@ fn overlap(selcx: &mut SelectionContext,
// Do `a` and `b` unify? If not, no overlap.
if let Err(_) = infer::mk_eq_trait_refs(selcx.infcx(),
true,
infer::Misc(DUMMY_SP),
TypeOrigin::Misc(DUMMY_SP),
a_trait_ref,
b_trait_ref) {
return false;

View File

@ -21,7 +21,7 @@ use super::VtableClosureData;
use super::VtableImplData;
use super::util;
use middle::infer;
use middle::infer::{self, TypeOrigin};
use middle::subst::Subst;
use middle::ty::{self, ToPredicate, RegionEscape, HasTypeFlags, ToPolyTraitRef, Ty};
use middle::ty::fold::{TypeFoldable, TypeFolder};
@ -138,7 +138,7 @@ fn project_and_unify_type<'cx,'tcx>(
obligations);
let infcx = selcx.infcx();
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
match infer::mk_eqty(infcx, true, origin, normalized_ty, obligation.predicate.ty) {
Ok(()) => Ok(Some(obligations)),
Err(err) => Err(MismatchedProjectionTypes { err: err }),
@ -183,7 +183,7 @@ fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext
debug!("consider_unification_despite_ambiguity: ret_type={:?}",
ret_type);
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
let obligation_ty = obligation.predicate.ty;
match infer::mk_eqty(infcx, true, origin, obligation_ty, ret_type) {
Ok(()) => { }
@ -645,7 +645,7 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>(
let same_name = data.item_name() == obligation.predicate.item_name;
let is_match = same_name && infcx.probe(|_| {
let origin = infer::Misc(obligation.cause.span);
let origin = TypeOrigin::Misc(obligation.cause.span);
let data_poly_trait_ref =
data.to_poly_trait_ref();
let obligation_poly_trait_ref =
@ -901,7 +901,7 @@ fn confirm_param_env_candidate<'cx,'tcx>(
assert_eq!(projection.projection_ty.item_name,
obligation.predicate.item_name);
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
match infcx.eq_trait_refs(false,
origin,
obligation.predicate.trait_ref.clone(),

View File

@ -38,7 +38,7 @@ use super::util;
use middle::def_id::DefId;
use middle::infer;
use middle::infer::{InferCtxt, TypeFreshener};
use middle::infer::{InferCtxt, TypeFreshener, TypeOrigin};
use middle::subst::{Subst, Substs, TypeSpace};
use middle::ty::{self, ToPredicate, RegionEscape, ToPolyTraitRef, Ty, HasTypeFlags};
use middle::ty::fast_reject;
@ -1155,7 +1155,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
-> bool
{
assert!(!skol_trait_ref.has_escaping_regions());
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
match self.infcx.sub_poly_trait_refs(false,
origin,
trait_bound.clone(),
@ -2444,7 +2444,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
expected_trait_ref: ty::PolyTraitRef<'tcx>)
-> Result<(), SelectionError<'tcx>>
{
let origin = infer::RelateOutputImplTypes(obligation_cause.span);
let origin = TypeOrigin::RelateOutputImplTypes(obligation_cause.span);
let obligation_trait_ref = obligation_trait_ref.clone();
match self.infcx.sub_poly_trait_refs(false,
@ -2483,7 +2483,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
};
let new_trait = tcx.mk_trait(data_a.principal.clone(), bounds);
let origin = infer::Misc(obligation.cause.span);
let origin = TypeOrigin::Misc(obligation.cause.span);
if self.infcx.sub_types(false, origin, new_trait, target).is_err() {
return Err(Unimplemented);
}
@ -2548,7 +2548,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// [T; n] -> [T].
(&ty::TyArray(a, _), &ty::TySlice(b)) => {
let origin = infer::Misc(obligation.cause.span);
let origin = TypeOrigin::Misc(obligation.cause.span);
if self.infcx.sub_types(false, origin, a, b).is_err() {
return Err(Unimplemented);
}
@ -2606,7 +2606,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
new_substs.types.get_mut_slice(TypeSpace)[i] = param_b;
}
let new_struct = tcx.mk_struct(def, tcx.mk_substs(new_substs));
let origin = infer::Misc(obligation.cause.span);
let origin = TypeOrigin::Misc(obligation.cause.span);
if self.infcx.sub_types(false, origin, new_struct, target).is_err() {
return Err(Unimplemented);
}
@ -2694,7 +2694,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
impl_trait_ref,
skol_obligation_trait_ref);
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
if let Err(e) = self.infcx.eq_trait_refs(false,
origin,
impl_trait_ref.value.clone(),
@ -2763,7 +2763,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation,
poly_trait_ref);
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
match self.infcx.sub_poly_trait_refs(false,
origin,
poly_trait_ref,

View File

@ -25,7 +25,7 @@ use rustc_typeck::middle::subst;
use rustc_typeck::middle::subst::Subst;
use rustc_typeck::middle::ty::{self, Ty, RegionEscape};
use rustc_typeck::middle::ty::relate::TypeRelation;
use rustc_typeck::middle::infer;
use rustc_typeck::middle::infer::{self, TypeOrigin};
use rustc_typeck::middle::infer::lub::Lub;
use rustc_typeck::middle::infer::glb::Glb;
use rustc_typeck::middle::infer::sub::Sub;
@ -230,7 +230,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
}
pub fn make_subtype(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
match infer::mk_subty(self.infcx, true, infer::Misc(DUMMY_SP), a, b) {
match infer::mk_subty(self.infcx, true, TypeOrigin::Misc(DUMMY_SP), a, b) {
Ok(_) => true,
Err(ref e) => panic!("Encountered error: {}", e),
}

View File

@ -9,7 +9,7 @@
// except according to those terms.
use middle::def;
use middle::infer;
use middle::infer::{self, TypeOrigin};
use middle::pat_util::{PatIdMap, pat_id_map, pat_is_binding};
use middle::pat_util::pat_is_resolved_const;
use middle::privacy::{AllPublic, LastMod};
@ -509,12 +509,12 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
/* if-let construct without an else block */
hir::MatchSource::IfLetDesugar { contains_else_clause }
if !contains_else_clause => (
infer::IfExpressionWithNoElse(expr.span),
TypeOrigin::IfExpressionWithNoElse(expr.span),
bty,
result_ty,
),
_ => (
infer::MatchExpressionArm(expr.span, arm.body.span, match_src),
TypeOrigin::MatchExpressionArm(expr.span, arm.body.span, match_src),
result_ty,
bty,
),

View File

@ -62,7 +62,7 @@
use check::{autoderef, FnCtxt, UnresolvedTypeAction};
use middle::infer::{self, Coercion};
use middle::infer::{self, Coercion, TypeOrigin};
use middle::traits::{self, ObligationCause};
use middle::traits::{predicate_for_trait_def, report_selection_error};
use middle::ty::adjustment::{AutoAdjustment, AutoDerefRef, AdjustDerefRef};
@ -444,7 +444,7 @@ pub fn mk_assignty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
fcx.infcx().commit_if_ok(|_| {
let coerce = Coerce {
fcx: fcx,
origin: infer::ExprAssignable(expr.span),
origin: TypeOrigin::ExprAssignable(expr.span),
unsizing_obligations: RefCell::new(vec![])
};
let adjustment = try!(coerce.coerce(expr, a, b));

View File

@ -9,7 +9,7 @@
// except according to those terms.
use middle::free_region::FreeRegionMap;
use middle::infer;
use middle::infer::{self, TypeOrigin};
use middle::traits;
use middle::ty::{self};
use middle::subst::{self, Subst, Substs, VecPerParamSpace};
@ -282,7 +282,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
let trait_fty = trait_fty.subst(tcx, &trait_to_skol_substs);
let err = infcx.commit_if_ok(|snapshot| {
let origin = infer::MethodCompatCheck(impl_m_span);
let origin = TypeOrigin::MethodCompatCheck(impl_m_span);
let (impl_sig, _) =
infcx.replace_late_bound_regions_with_fresh_var(impl_m_span,
@ -448,7 +448,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>,
let trait_ty = trait_c.ty.subst(tcx, &trait_to_skol_substs);
let err = infcx.commit_if_ok(|_| {
let origin = infer::Misc(impl_c_span);
let origin = TypeOrigin::Misc(impl_c_span);
// There is no "body" here, so just pass dummy id.
let impl_ty =

View File

@ -11,7 +11,7 @@
use check::{coercion, FnCtxt};
use middle::ty::{self, Ty};
use middle::infer;
use middle::infer::{self, TypeOrigin};
use std::result::Result::{Err, Ok};
use syntax::codemap::Span;
@ -35,7 +35,7 @@ pub fn suptype_with_fn<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
F: FnOnce(Span, Ty<'tcx>, Ty<'tcx>, &ty::error::TypeError<'tcx>),
{
// n.b.: order of actual, expected is reversed
match infer::mk_subty(fcx.infcx(), b_is_expected, infer::Misc(sp),
match infer::mk_subty(fcx.infcx(), b_is_expected, TypeOrigin::Misc(sp),
ty_b, ty_a) {
Ok(()) => { /* ok */ }
Err(ref err) => {
@ -46,7 +46,7 @@ pub fn suptype_with_fn<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
pub fn eqtype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
expected: Ty<'tcx>, actual: Ty<'tcx>) {
match infer::mk_eqty(fcx.infcx(), false, infer::Misc(sp), actual, expected) {
match infer::mk_eqty(fcx.infcx(), false, TypeOrigin::Misc(sp), actual, expected) {
Ok(()) => { /* ok */ }
Err(ref err) => { fcx.report_mismatched_types(sp, expected, actual, err); }
}

View File

@ -19,7 +19,7 @@ use middle::ty::{self, NoPreference, PreferMutLvalue, Ty};
use middle::ty::adjustment::{AdjustDerefRef, AutoDerefRef, AutoPtr};
use middle::ty::fold::TypeFoldable;
use middle::infer;
use middle::infer::InferCtxt;
use middle::infer::{InferCtxt, TypeOrigin};
use syntax::codemap::Span;
use rustc_front::hir;
@ -367,7 +367,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
self_ty: Ty<'tcx>,
method_self_ty: Ty<'tcx>)
{
match self.fcx.mk_subty(false, infer::Misc(self.span), self_ty, method_self_ty) {
match self.fcx.mk_subty(false, TypeOrigin::Misc(self.span), self_ty, method_self_ty) {
Ok(_) => {}
Err(_) => {
self.tcx().sess.span_bug(

View File

@ -23,7 +23,7 @@ use middle::ty::{self, NoPreference, RegionEscape, Ty, ToPolyTraitRef, TraitRef}
use middle::ty::HasTypeFlags;
use middle::ty::fold::TypeFoldable;
use middle::infer;
use middle::infer::InferCtxt;
use middle::infer::{InferCtxt, TypeOrigin};
use syntax::ast;
use syntax::codemap::{Span, DUMMY_SP};
use rustc_front::hir;
@ -1136,7 +1136,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
// MISCELLANY
fn make_sub_ty(&self, sub: Ty<'tcx>, sup: Ty<'tcx>) -> infer::UnitResult<'tcx> {
self.infcx().sub_types(false, infer::Misc(DUMMY_SP), sub, sup)
self.infcx().sub_types(false, TypeOrigin::Misc(DUMMY_SP), sub, sup)
}
fn has_applicable_self(&self, item: &ty::ImplOrTraitItem) -> bool {

View File

@ -88,7 +88,7 @@ use middle::astconv_util::prohibit_type_params;
use middle::def;
use middle::def_id::DefId;
use middle::infer;
use middle::infer::type_variable;
use middle::infer::{TypeOrigin, type_variable};
use middle::pat_util::{self, pat_id_map};
use middle::privacy::{AllPublic, LastMod};
use middle::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace, TypeSpace};
@ -1610,7 +1610,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn mk_subty(&self,
a_is_expected: bool,
origin: infer::TypeOrigin,
origin: TypeOrigin,
sub: Ty<'tcx>,
sup: Ty<'tcx>)
-> Result<(), TypeError<'tcx>> {
@ -1619,7 +1619,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn mk_eqty(&self,
a_is_expected: bool,
origin: infer::TypeOrigin,
origin: TypeOrigin,
sub: Ty<'tcx>,
sup: Ty<'tcx>)
-> Result<(), TypeError<'tcx>> {
@ -1897,7 +1897,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Some(default) = default_map.get(ty) {
let default = default.clone();
match infer::mk_eqty(self.infcx(), false,
infer::Misc(default.origin_span),
TypeOrigin::Misc(default.origin_span),
ty, default.ty) {
Ok(()) => {}
Err(_) => {
@ -1990,7 +1990,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Some(default) = default_map.get(ty) {
let default = default.clone();
match infer::mk_eqty(self.infcx(), false,
infer::Misc(default.origin_span),
TypeOrigin::Misc(default.origin_span),
ty, default.ty) {
Ok(()) => {}
Err(_) => {
@ -2784,7 +2784,7 @@ fn expected_types_for_fn_args<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// return type (likely containing type variables if the function
// is polymorphic) and the expected return type.
// No argument expectations are produced if unification fails.
let origin = infer::Misc(call_span);
let origin = TypeOrigin::Misc(call_span);
let ures = fcx.infcx().sub_types(false, origin, formal_ret_ty, ret_ty);
// FIXME(#15760) can't use try! here, FromError doesn't default
// to identity so the resulting type is not constrained.
@ -2898,14 +2898,14 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
check_expr_with_expectation(fcx, &**else_expr, expected);
let else_ty = fcx.expr_ty(&**else_expr);
infer::common_supertype(fcx.infcx(),
infer::IfExpression(sp),
TypeOrigin::IfExpression(sp),
true,
then_ty,
else_ty)
}
None => {
infer::common_supertype(fcx.infcx(),
infer::IfExpressionWithNoElse(sp),
TypeOrigin::IfExpressionWithNoElse(sp),
false,
then_ty,
fcx.tcx().mk_nil())
@ -3405,7 +3405,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
ty::FnConverging(result_type) => {
match *expr_opt {
None =>
if let Err(_) = fcx.mk_eqty(false, infer::Misc(expr.span),
if let Err(_) = fcx.mk_eqty(false, TypeOrigin::Misc(expr.span),
result_type, fcx.tcx().mk_nil()) {
span_err!(tcx.sess, expr.span, E0069,
"`return;` in a function whose return type is \
@ -3689,7 +3689,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
}
(Some(t_start), Some(t_end)) => {
Some(infer::common_supertype(fcx.infcx(),
infer::RangeExpression(expr.span),
TypeOrigin::RangeExpression(expr.span),
true,
t_start,
t_end))
@ -4585,7 +4585,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
impl_scheme.generics.regions.len(subst::TypeSpace));
let impl_ty = fcx.instantiate_type_scheme(span, &substs, &impl_scheme.ty);
if fcx.mk_subty(false, infer::Misc(span), self_ty, impl_ty).is_err() {
if fcx.mk_subty(false, TypeOrigin::Misc(span), self_ty, impl_ty).is_err() {
fcx.tcx().sess.span_bug(span,
&format!(
"instantiate_path: (UFCS) {:?} was a subtype of {:?} but now is not?",

View File

@ -93,7 +93,7 @@ use middle::region::CodeExtent;
use middle::subst::Substs;
use middle::traits;
use middle::ty::{self, RegionEscape, ReScope, Ty, MethodCall, HasTypeFlags};
use middle::infer::{self, GenericKind, InferCtxt, SubregionOrigin, VerifyBound};
use middle::infer::{self, GenericKind, InferCtxt, SubregionOrigin, TypeOrigin, VerifyBound};
use middle::pat_util;
use middle::ty::adjustment;
use middle::ty::wf::ImpliedBound;
@ -1868,7 +1868,7 @@ fn declared_projection_bounds_from_trait<'a,'tcx>(rcx: &Rcx<'a, 'tcx>,
outlives);
// check whether this predicate applies to our current projection
match infer::mk_eqty(infcx, false, infer::Misc(span), ty, outlives.0) {
match infer::mk_eqty(infcx, false, TypeOrigin::Misc(span), ty, outlives.0) {
Ok(()) => { Ok(outlives.1) }
Err(_) => { Err(()) }
}

View File

@ -33,7 +33,7 @@ use middle::ty::TyProjection;
use middle::ty::util::CopyImplementationError;
use middle::free_region::FreeRegionMap;
use CrateCtxt;
use middle::infer::{self, InferCtxt, new_infer_ctxt};
use middle::infer::{self, InferCtxt, TypeOrigin, new_infer_ctxt};
use std::cell::RefCell;
use std::rc::Rc;
use syntax::codemap::Span;
@ -406,7 +406,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
return;
}
let origin = infer::Misc(span);
let origin = TypeOrigin::Misc(span);
let fields = &def_a.struct_variant().fields;
let diff_fields = fields.iter().enumerate().filter_map(|(i, f)| {
let (a, b) = (f.ty(tcx, substs_a), f.ty(tcx, substs_b));

View File

@ -106,7 +106,7 @@ pub use rustc::util;
use front::map as hir_map;
use middle::def;
use middle::infer;
use middle::infer::{self, TypeOrigin};
use middle::subst;
use middle::ty::{self, Ty, HasTypeFlags};
use session::config;
@ -200,10 +200,10 @@ fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>,
let result = match maybe_infcx {
None => {
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
infer::mk_eqty(&infcx, t1_is_expected, infer::Misc(span), t1, t2)
infer::mk_eqty(&infcx, t1_is_expected, TypeOrigin::Misc(span), t1, t2)
}
Some(infcx) => {
infer::mk_eqty(infcx, t1_is_expected, infer::Misc(span), t1, t2)
infer::mk_eqty(infcx, t1_is_expected, TypeOrigin::Misc(span), t1, t2)
}
};