Remove TypeVariableOriginKind
This commit is contained in:
parent
99d0186b1d
commit
34bce07e8e
@ -11,7 +11,7 @@ use std::assert_matches::assert_matches;
|
|||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::{BoundRegionConversionTime, RegionVariableOrigin};
|
use rustc_infer::infer::{BoundRegionConversionTime, RegionVariableOrigin};
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
@ -75,10 +75,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let next_ty_var = || {
|
let next_ty_var = || {
|
||||||
self.infcx.next_ty_var(TypeVariableOrigin {
|
self.infcx.next_ty_var(TypeVariableOrigin { span: body.span, param_def_id: None })
|
||||||
span: body.span,
|
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
let output_ty = Ty::new_coroutine(
|
let output_ty = Ty::new_coroutine(
|
||||||
self.tcx(),
|
self.tcx(),
|
||||||
|
@ -16,7 +16,7 @@ use rustc_index::{IndexSlice, IndexVec};
|
|||||||
use rustc_infer::infer::canonical::QueryRegionConstraints;
|
use rustc_infer::infer::canonical::QueryRegionConstraints;
|
||||||
use rustc_infer::infer::outlives::env::RegionBoundPairs;
|
use rustc_infer::infer::outlives::env::RegionBoundPairs;
|
||||||
use rustc_infer::infer::region_constraints::RegionConstraintData;
|
use rustc_infer::infer::region_constraints::RegionConstraintData;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::{
|
use rustc_infer::infer::{
|
||||||
BoundRegion, BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin,
|
BoundRegion, BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin,
|
||||||
};
|
};
|
||||||
@ -2425,7 +2425,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
ty::RawPtr(_, _) | ty::FnPtr(_) => {
|
ty::RawPtr(_, _) | ty::FnPtr(_) => {
|
||||||
let ty_right = right.ty(body, tcx);
|
let ty_right = right.ty(body, tcx);
|
||||||
let common_ty = self.infcx.next_ty_var(TypeVariableOrigin {
|
let common_ty = self.infcx.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
param_def_id: None,
|
||||||
span: body.source_info(location).span,
|
span: body.source_info(location).span,
|
||||||
});
|
});
|
||||||
self.sub_types(
|
self.sub_types(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::ErrorGuaranteed;
|
use rustc_errors::ErrorGuaranteed;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::NllRegionVariableOrigin;
|
use rustc_infer::infer::NllRegionVariableOrigin;
|
||||||
use rustc_infer::infer::{ObligationEmittingRelation, StructurallyRelateAliases};
|
use rustc_infer::infer::{ObligationEmittingRelation, StructurallyRelateAliases};
|
||||||
use rustc_infer::traits::{Obligation, PredicateObligations};
|
use rustc_infer::traits::{Obligation, PredicateObligations};
|
||||||
@ -129,10 +129,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
|
|||||||
// the opaque.
|
// the opaque.
|
||||||
let mut enable_subtyping = |ty, opaque_is_expected| {
|
let mut enable_subtyping = |ty, opaque_is_expected| {
|
||||||
let ty_vid = infcx.next_ty_var_id_in_universe(
|
let ty_vid = infcx.next_ty_var_id_in_universe(
|
||||||
TypeVariableOrigin {
|
TypeVariableOrigin { param_def_id: None, span: self.span() },
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: self.span(),
|
|
||||||
},
|
|
||||||
ty::UniverseIndex::ROOT,
|
ty::UniverseIndex::ROOT,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use rustc_hir::def::{DefKind, Res};
|
|||||||
use rustc_hir::intravisit;
|
use rustc_hir::intravisit;
|
||||||
use rustc_hir::{GenericParamKind, ImplItemKind};
|
use rustc_hir::{GenericParamKind, ImplItemKind};
|
||||||
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
|
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
|
||||||
use rustc_infer::traits::{util, FulfillmentError};
|
use rustc_infer::traits::{util, FulfillmentError};
|
||||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||||
@ -800,10 +800,10 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
|
|||||||
bug!("FIXME(RPITIT): error here");
|
bug!("FIXME(RPITIT): error here");
|
||||||
}
|
}
|
||||||
// Replace with infer var
|
// Replace with infer var
|
||||||
let infer_ty = self.ocx.infcx.next_ty_var(TypeVariableOrigin {
|
let infer_ty = self
|
||||||
span: self.span,
|
.ocx
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
.infcx
|
||||||
});
|
.next_ty_var(TypeVariableOrigin { span: self.span, param_def_id: None });
|
||||||
self.types.insert(proj.def_id, (infer_ty, proj.args));
|
self.types.insert(proj.def_id, (infer_ty, proj.args));
|
||||||
// Recurse into bounds
|
// Recurse into bounds
|
||||||
for (pred, pred_span) in self
|
for (pred, pred_span) in self
|
||||||
|
@ -5,7 +5,7 @@ use rustc_hir::def::{CtorOf, DefKind, Res};
|
|||||||
use rustc_hir::def_id::LocalDefId;
|
use rustc_hir::def_id::LocalDefId;
|
||||||
use rustc_hir::{self as hir, ExprKind, PatKind};
|
use rustc_hir::{self as hir, ExprKind, PatKind};
|
||||||
use rustc_hir_pretty::ty_to_string;
|
use rustc_hir_pretty::ty_to_string;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_trait_selection::traits::{
|
use rustc_trait_selection::traits::{
|
||||||
@ -67,10 +67,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// arm for inconsistent arms or to the whole match when a `()` type
|
// arm for inconsistent arms or to the whole match when a `()` type
|
||||||
// is required).
|
// is required).
|
||||||
Expectation::ExpectHasType(ety) if ety != Ty::new_unit(self.tcx) => ety,
|
Expectation::ExpectHasType(ety) if ety != Ty::new_unit(self.tcx) => ety,
|
||||||
_ => self.next_ty_var(TypeVariableOrigin {
|
_ => self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr.span }),
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: expr.span,
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
CoerceMany::with_coercion_sites(coerce_first, arms)
|
CoerceMany::with_coercion_sites(coerce_first, arms)
|
||||||
};
|
};
|
||||||
@ -578,10 +575,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// ...but otherwise we want to use any supertype of the
|
// ...but otherwise we want to use any supertype of the
|
||||||
// scrutinee. This is sort of a workaround, see note (*) in
|
// scrutinee. This is sort of a workaround, see note (*) in
|
||||||
// `check_pat` for some details.
|
// `check_pat` for some details.
|
||||||
let scrut_ty = self.next_ty_var(TypeVariableOrigin {
|
let scrut_ty =
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: scrut.span });
|
||||||
span: scrut.span,
|
|
||||||
});
|
|
||||||
self.check_expr_has_type_or_error(scrut, scrut_ty, |_| {});
|
self.check_expr_has_type_or_error(scrut, scrut_ty, |_| {});
|
||||||
scrut_ty
|
scrut_ty
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,7 @@ use rustc_infer::{
|
|||||||
infer,
|
infer,
|
||||||
traits::{self, Obligation},
|
traits::{self, Obligation},
|
||||||
};
|
};
|
||||||
use rustc_infer::{
|
use rustc_infer::{infer::type_variable::TypeVariableOrigin, traits::ObligationCause};
|
||||||
infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind},
|
|
||||||
traits::ObligationCause,
|
|
||||||
};
|
|
||||||
use rustc_middle::ty::adjustment::{
|
use rustc_middle::ty::adjustment::{
|
||||||
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
|
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
|
||||||
};
|
};
|
||||||
@ -180,18 +177,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
infer::FnCall,
|
infer::FnCall,
|
||||||
closure_args.coroutine_closure_sig(),
|
closure_args.coroutine_closure_sig(),
|
||||||
);
|
);
|
||||||
let tupled_upvars_ty = self.next_ty_var(TypeVariableOrigin {
|
let tupled_upvars_ty = self
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: callee_expr.span });
|
||||||
span: callee_expr.span,
|
|
||||||
});
|
|
||||||
// We may actually receive a coroutine back whose kind is different
|
// We may actually receive a coroutine back whose kind is different
|
||||||
// from the closure that this dispatched from. This is because when
|
// from the closure that this dispatched from. This is because when
|
||||||
// we have no captures, we automatically implement `FnOnce`. This
|
// we have no captures, we automatically implement `FnOnce`. This
|
||||||
// impl forces the closure kind to `FnOnce` i.e. `u8`.
|
// impl forces the closure kind to `FnOnce` i.e. `u8`.
|
||||||
let kind_ty = self.next_ty_var(TypeVariableOrigin {
|
let kind_ty = self
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: callee_expr.span });
|
||||||
span: callee_expr.span,
|
|
||||||
});
|
|
||||||
let call_sig = self.tcx.mk_fn_sig(
|
let call_sig = self.tcx.mk_fn_sig(
|
||||||
[coroutine_closure_sig.tupled_inputs_ty],
|
[coroutine_closure_sig.tupled_inputs_ty],
|
||||||
coroutine_closure_sig.to_coroutine(
|
coroutine_closure_sig.to_coroutine(
|
||||||
@ -305,10 +298,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
Ty::new_tup_from_iter(
|
Ty::new_tup_from_iter(
|
||||||
self.tcx,
|
self.tcx,
|
||||||
arg_exprs.iter().map(|e| {
|
arg_exprs.iter().map(|e| {
|
||||||
self.next_ty_var(TypeVariableOrigin {
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: e.span })
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
|
||||||
span: e.span,
|
|
||||||
})
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@ use rustc_hir::def::DefKind;
|
|||||||
use rustc_hir::intravisit::Visitor;
|
use rustc_hir::intravisit::Visitor;
|
||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
use rustc_hir_analysis::check::{check_function_signature, forbid_intrinsic_abi};
|
use rustc_hir_analysis::check::{check_function_signature, forbid_intrinsic_abi};
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::RegionVariableOrigin;
|
use rustc_infer::infer::RegionVariableOrigin;
|
||||||
use rustc_middle::ty::{self, Binder, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Binder, Ty, TyCtxt};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
@ -123,8 +123,7 @@ pub(super) fn check_fn<'a, 'tcx>(
|
|||||||
// We have special-cased the case where the function is declared
|
// We have special-cased the case where the function is declared
|
||||||
// `-> dyn Foo` and we don't actually relate it to the
|
// `-> dyn Foo` and we don't actually relate it to the
|
||||||
// `fcx.ret_coercion`, so just instantiate a type variable.
|
// `fcx.ret_coercion`, so just instantiate a type variable.
|
||||||
actual_return_ty =
|
actual_return_ty = fcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span });
|
||||||
fcx.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::DynReturnFn, span });
|
|
||||||
debug!("actual_return_ty replaced with {:?}", actual_return_ty);
|
debug!("actual_return_ty replaced with {:?}", actual_return_ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use rustc_errors::ErrorGuaranteed;
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
|
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
|
||||||
use rustc_infer::infer::{InferOk, InferResult};
|
use rustc_infer::infer::{InferOk, InferResult};
|
||||||
use rustc_macros::{TypeFoldable, TypeVisitable};
|
use rustc_macros::{TypeFoldable, TypeVisitable};
|
||||||
@ -72,10 +72,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let parent_args =
|
let parent_args =
|
||||||
GenericArgs::identity_for_item(tcx, tcx.typeck_root_def_id(expr_def_id.to_def_id()));
|
GenericArgs::identity_for_item(tcx, tcx.typeck_root_def_id(expr_def_id.to_def_id()));
|
||||||
|
|
||||||
let tupled_upvars_ty = self.next_ty_var(TypeVariableOrigin {
|
let tupled_upvars_ty =
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
|
||||||
span: expr_span,
|
|
||||||
});
|
|
||||||
|
|
||||||
// FIXME: We could probably actually just unify this further --
|
// FIXME: We could probably actually just unify this further --
|
||||||
// instead of having a `FnSig` and a `Option<CoroutineTypes>`,
|
// instead of having a `FnSig` and a `Option<CoroutineTypes>`,
|
||||||
@ -104,7 +102,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// It will be unified during the upvar inference phase (`upvar.rs`)
|
// It will be unified during the upvar inference phase (`upvar.rs`)
|
||||||
None => self.next_ty_var(TypeVariableOrigin {
|
None => self.next_ty_var(TypeVariableOrigin {
|
||||||
// FIXME(eddyb) distinguish closure kind inference variables from the rest.
|
// FIXME(eddyb) distinguish closure kind inference variables from the rest.
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
param_def_id: None,
|
||||||
span: expr_span,
|
span: expr_span,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@ -126,7 +124,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _)
|
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _)
|
||||||
| hir::CoroutineKind::Coroutine(_) => {
|
| hir::CoroutineKind::Coroutine(_) => {
|
||||||
let yield_ty = self.next_ty_var(TypeVariableOrigin {
|
let yield_ty = self.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
param_def_id: None,
|
||||||
span: expr_span,
|
span: expr_span,
|
||||||
});
|
});
|
||||||
self.require_type_is_sized(yield_ty, expr_span, traits::SizedYieldType);
|
self.require_type_is_sized(yield_ty, expr_span, traits::SizedYieldType);
|
||||||
@ -138,7 +136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// not a problem.
|
// not a problem.
|
||||||
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, _) => {
|
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, _) => {
|
||||||
let yield_ty = self.next_ty_var(TypeVariableOrigin {
|
let yield_ty = self.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
param_def_id: None,
|
||||||
span: expr_span,
|
span: expr_span,
|
||||||
});
|
});
|
||||||
self.require_type_is_sized(yield_ty, expr_span, traits::SizedYieldType);
|
self.require_type_is_sized(yield_ty, expr_span, traits::SizedYieldType);
|
||||||
@ -166,10 +164,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// Resume type defaults to `()` if the coroutine has no argument.
|
// Resume type defaults to `()` if the coroutine has no argument.
|
||||||
let resume_ty = liberated_sig.inputs().get(0).copied().unwrap_or(tcx.types.unit);
|
let resume_ty = liberated_sig.inputs().get(0).copied().unwrap_or(tcx.types.unit);
|
||||||
|
|
||||||
let interior = self.next_ty_var(TypeVariableOrigin {
|
let interior =
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
|
||||||
span: expr_span,
|
|
||||||
});
|
|
||||||
self.deferred_coroutine_interiors.borrow_mut().push((
|
self.deferred_coroutine_interiors.borrow_mut().push((
|
||||||
expr_def_id,
|
expr_def_id,
|
||||||
body.id(),
|
body.id(),
|
||||||
@ -181,11 +177,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// later during upvar analysis. Regular coroutines always have the kind
|
// later during upvar analysis. Regular coroutines always have the kind
|
||||||
// ty of `().`
|
// ty of `().`
|
||||||
let kind_ty = match kind {
|
let kind_ty = match kind {
|
||||||
hir::CoroutineKind::Desugared(_, hir::CoroutineSource::Closure) => self
|
hir::CoroutineKind::Desugared(_, hir::CoroutineSource::Closure) => {
|
||||||
.next_ty_var(TypeVariableOrigin {
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span })
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
}
|
||||||
span: expr_span,
|
|
||||||
}),
|
|
||||||
_ => tcx.types.unit,
|
_ => tcx.types.unit,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -219,30 +213,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Compute all of the variables that will be used to populate the coroutine.
|
// Compute all of the variables that will be used to populate the coroutine.
|
||||||
let resume_ty = self.next_ty_var(TypeVariableOrigin {
|
let resume_ty =
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
|
||||||
span: expr_span,
|
let interior =
|
||||||
});
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
|
||||||
let interior = self.next_ty_var(TypeVariableOrigin {
|
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
|
||||||
span: expr_span,
|
|
||||||
});
|
|
||||||
|
|
||||||
let closure_kind_ty = match expected_kind {
|
let closure_kind_ty = match expected_kind {
|
||||||
Some(kind) => Ty::from_closure_kind(tcx, kind),
|
Some(kind) => Ty::from_closure_kind(tcx, kind),
|
||||||
|
|
||||||
// Create a type variable (for now) to represent the closure kind.
|
// Create a type variable (for now) to represent the closure kind.
|
||||||
// It will be unified during the upvar inference phase (`upvar.rs`)
|
// It will be unified during the upvar inference phase (`upvar.rs`)
|
||||||
None => self.next_ty_var(TypeVariableOrigin {
|
None => {
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span })
|
||||||
span: expr_span,
|
}
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let coroutine_captures_by_ref_ty = self.next_ty_var(TypeVariableOrigin {
|
let coroutine_captures_by_ref_ty =
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
|
||||||
span: expr_span,
|
|
||||||
});
|
|
||||||
let closure_args = ty::CoroutineClosureArgs::new(
|
let closure_args = ty::CoroutineClosureArgs::new(
|
||||||
tcx,
|
tcx,
|
||||||
ty::CoroutineClosureArgsParts {
|
ty::CoroutineClosureArgsParts {
|
||||||
@ -274,16 +261,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
// Create a type variable (for now) to represent the closure kind.
|
// Create a type variable (for now) to represent the closure kind.
|
||||||
// It will be unified during the upvar inference phase (`upvar.rs`)
|
// It will be unified during the upvar inference phase (`upvar.rs`)
|
||||||
None => self.next_ty_var(TypeVariableOrigin {
|
None => {
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span })
|
||||||
span: expr_span,
|
}
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let coroutine_upvars_ty = self.next_ty_var(TypeVariableOrigin {
|
let coroutine_upvars_ty =
|
||||||
kind: TypeVariableOriginKind::ClosureSynthetic,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
|
||||||
span: expr_span,
|
|
||||||
});
|
|
||||||
|
|
||||||
// We need to turn the liberated signature that we got from HIR, which
|
// We need to turn the liberated signature that we got from HIR, which
|
||||||
// looks something like `|Args...| -> T`, into a signature that is suitable
|
// looks something like `|Args...| -> T`, into a signature that is suitable
|
||||||
|
@ -43,7 +43,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
|
|||||||
use rustc_hir::intravisit::{self, Visitor};
|
use rustc_hir::intravisit::{self, Visitor};
|
||||||
use rustc_hir::Expr;
|
use rustc_hir::Expr;
|
||||||
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::{Coercion, DefineOpaqueTypes, InferOk, InferResult};
|
use rustc_infer::infer::{Coercion, DefineOpaqueTypes, InferOk, InferResult};
|
||||||
use rustc_infer::traits::TraitEngineExt as _;
|
use rustc_infer::traits::TraitEngineExt as _;
|
||||||
use rustc_infer::traits::{IfExpressionCause, MatchExpressionArmCause, TraitEngine};
|
use rustc_infer::traits::{IfExpressionCause, MatchExpressionArmCause, TraitEngine};
|
||||||
@ -279,10 +279,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||||||
if b.is_ty_var() {
|
if b.is_ty_var() {
|
||||||
// Two unresolved type variables: create a `Coerce` predicate.
|
// Two unresolved type variables: create a `Coerce` predicate.
|
||||||
let target_ty = if self.use_lub {
|
let target_ty = if self.use_lub {
|
||||||
self.next_ty_var(TypeVariableOrigin {
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.cause.span })
|
||||||
kind: TypeVariableOriginKind::LatticeVariable,
|
|
||||||
span: self.cause.span,
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
b
|
b
|
||||||
};
|
};
|
||||||
@ -581,10 +578,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||||||
// the `CoerceUnsized` target type and the expected type.
|
// the `CoerceUnsized` target type and the expected type.
|
||||||
// We only have the latter, so we use an inference variable
|
// We only have the latter, so we use an inference variable
|
||||||
// for the former and let type inference do the rest.
|
// for the former and let type inference do the rest.
|
||||||
let origin = TypeVariableOrigin {
|
let origin = TypeVariableOrigin { param_def_id: None, span: self.cause.span };
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: self.cause.span,
|
|
||||||
};
|
|
||||||
let coerce_target = self.next_ty_var(origin);
|
let coerce_target = self.next_ty_var(origin);
|
||||||
let mut coercion = self.unify_and(coerce_target, target, |target| {
|
let mut coercion = self.unify_and(coerce_target, target, |target| {
|
||||||
let unsize = Adjustment { kind: Adjust::Pointer(PointerCoercion::Unsize), target };
|
let unsize = Adjustment { kind: Adjust::Pointer(PointerCoercion::Unsize), target };
|
||||||
|
@ -337,10 +337,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
ty_op: |ty| {
|
ty_op: |ty| {
|
||||||
if let ty::Infer(infer) = ty.kind() {
|
if let ty::Infer(infer) = ty.kind() {
|
||||||
match infer {
|
match infer {
|
||||||
ty::TyVar(_) => self.next_ty_var(TypeVariableOrigin {
|
ty::TyVar(_) => self
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: DUMMY_SP }),
|
||||||
span: DUMMY_SP,
|
|
||||||
}),
|
|
||||||
ty::IntVar(_) => self.next_int_var(),
|
ty::IntVar(_) => self.next_int_var(),
|
||||||
ty::FloatVar(_) => self.next_float_var(),
|
ty::FloatVar(_) => self.next_float_var(),
|
||||||
ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {
|
ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
@ -110,8 +110,7 @@ impl<'a, 'tcx> Expectation<'tcx> {
|
|||||||
/// Like `only_has_type`, but instead of returning `None` if no
|
/// Like `only_has_type`, but instead of returning `None` if no
|
||||||
/// hard constraint exists, creates a fresh type variable.
|
/// hard constraint exists, creates a fresh type variable.
|
||||||
pub(super) fn coercion_target_type(self, fcx: &FnCtxt<'a, 'tcx>, span: Span) -> Ty<'tcx> {
|
pub(super) fn coercion_target_type(self, fcx: &FnCtxt<'a, 'tcx>, span: Span) -> Ty<'tcx> {
|
||||||
self.only_has_type(fcx).unwrap_or_else(|| {
|
self.only_has_type(fcx)
|
||||||
fcx.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span })
|
.unwrap_or_else(|| fcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span }))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ use rustc_hir::{ExprKind, HirId, QPath};
|
|||||||
use rustc_hir_analysis::check::ty_kind_suggestion;
|
use rustc_hir_analysis::check::ty_kind_suggestion;
|
||||||
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _;
|
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _;
|
||||||
use rustc_infer::infer;
|
use rustc_infer::infer;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::DefineOpaqueTypes;
|
use rustc_infer::infer::DefineOpaqueTypes;
|
||||||
use rustc_infer::infer::InferOk;
|
use rustc_infer::infer::InferOk;
|
||||||
use rustc_infer::traits::query::NoSolution;
|
use rustc_infer::traits::query::NoSolution;
|
||||||
@ -81,10 +81,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
return Ty::new_error(self.tcx(), reported);
|
return Ty::new_error(self.tcx(), reported);
|
||||||
}
|
}
|
||||||
|
|
||||||
let adj_ty = self.next_ty_var(TypeVariableOrigin {
|
let adj_ty =
|
||||||
kind: TypeVariableOriginKind::AdjustmentType,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr.span });
|
||||||
span: expr.span,
|
|
||||||
});
|
|
||||||
self.apply_adjustments(
|
self.apply_adjustments(
|
||||||
expr,
|
expr,
|
||||||
vec![Adjustment { kind: Adjust::NeverToAny, target: adj_ty }],
|
vec![Adjustment { kind: Adjust::NeverToAny, target: adj_ty }],
|
||||||
@ -1418,10 +1416,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
self.next_ty_var(TypeVariableOrigin {
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr.span })
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
|
||||||
span: expr.span,
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
let mut coerce = CoerceMany::with_coercion_sites(coerce_to, args);
|
let mut coerce = CoerceMany::with_coercion_sites(coerce_to, args);
|
||||||
assert_eq!(self.diverges.get(), Diverges::Maybe);
|
assert_eq!(self.diverges.get(), Diverges::Maybe);
|
||||||
@ -1432,10 +1427,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
coerce.complete(self)
|
coerce.complete(self)
|
||||||
} else {
|
} else {
|
||||||
self.next_ty_var(TypeVariableOrigin {
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr.span })
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
|
||||||
span: expr.span,
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
let array_len = args.len() as u64;
|
let array_len = args.len() as u64;
|
||||||
self.suggest_array_len(expr, array_len);
|
self.suggest_array_len(expr, array_len);
|
||||||
@ -1518,10 +1510,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
(uty, uty)
|
(uty, uty)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let ty = self.next_ty_var(TypeVariableOrigin {
|
let ty =
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: element.span });
|
||||||
span: element.span,
|
|
||||||
});
|
|
||||||
let element_ty = self.check_expr_has_type_or_error(element, ty, |_| {});
|
let element_ty = self.check_expr_has_type_or_error(element, ty, |_| {});
|
||||||
(element_ty, ty)
|
(element_ty, ty)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use crate::FnCtxt;
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_infer::{infer::type_variable::TypeVariableOriginKind, traits::ObligationCauseCode};
|
use rustc_infer::traits::ObligationCauseCode;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
|
||||||
use rustc_span::{symbol::kw, Span};
|
use rustc_span::{symbol::kw, Span};
|
||||||
use rustc_trait_selection::traits;
|
use rustc_trait_selection::traits;
|
||||||
@ -340,7 +340,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
type Result = ControlFlow<ty::GenericArg<'tcx>>;
|
type Result = ControlFlow<ty::GenericArg<'tcx>>;
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
|
||||||
if let Some(origin) = self.0.type_var_origin(ty)
|
if let Some(origin) = self.0.type_var_origin(ty)
|
||||||
&& let TypeVariableOriginKind::TypeParameterDefinition(_, def_id) = origin.kind
|
&& let Some(def_id) = origin.param_def_id
|
||||||
&& let generics = self.0.tcx.generics_of(self.1)
|
&& let generics = self.0.tcx.generics_of(self.1)
|
||||||
&& let Some(index) = generics.param_def_id_to_index(self.0.tcx, def_id)
|
&& let Some(index) = generics.param_def_id_to_index(self.0.tcx, def_id)
|
||||||
&& let Some(arg) =
|
&& let Some(arg) =
|
||||||
|
@ -31,7 +31,7 @@ use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
|||||||
use rustc_hir_analysis::structured_errors::StructuredDiag;
|
use rustc_hir_analysis::structured_errors::StructuredDiag;
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
use rustc_infer::infer::error_reporting::{FailureCode, ObligationCauseExt};
|
use rustc_infer::infer::error_reporting::{FailureCode, ObligationCauseExt};
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::TypeTrace;
|
use rustc_infer::infer::TypeTrace;
|
||||||
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
|
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
|
||||||
use rustc_middle::traits::ObligationCauseCode::ExprBindingObligation;
|
use rustc_middle::traits::ObligationCauseCode::ExprBindingObligation;
|
||||||
@ -2184,7 +2184,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
[
|
[
|
||||||
callee_ty,
|
callee_ty,
|
||||||
self.next_ty_var(TypeVariableOrigin {
|
self.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
param_def_id: None,
|
||||||
span: rustc_span::DUMMY_SP,
|
span: rustc_span::DUMMY_SP,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
@ -16,7 +16,7 @@ use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
|||||||
use rustc_infer::infer;
|
use rustc_infer::infer;
|
||||||
use rustc_infer::infer::error_reporting::sub_relations::SubRelations;
|
use rustc_infer::infer::error_reporting::sub_relations::SubRelations;
|
||||||
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||||
use rustc_middle::ty::{self, Const, Ty, TyCtxt, TypeVisitableExt};
|
use rustc_middle::ty::{self, Const, Ty, TyCtxt, TypeVisitableExt};
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
@ -236,10 +236,7 @@ impl<'a, 'tcx> HirTyLowerer<'tcx> for FnCtxt<'a, 'tcx> {
|
|||||||
fn ty_infer(&self, param: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> {
|
fn ty_infer(&self, param: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> {
|
||||||
match param {
|
match param {
|
||||||
Some(param) => self.var_for_def(span, param).as_type().unwrap(),
|
Some(param) => self.var_for_def(span, param).as_type().unwrap(),
|
||||||
None => self.next_ty_var(TypeVariableOrigin {
|
None => self.next_ty_var(TypeVariableOrigin { param_def_id: None, span }),
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
|
||||||
span,
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use crate::FnCtxt;
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::intravisit::{self, Visitor};
|
use rustc_hir::intravisit::{self, Visitor};
|
||||||
use rustc_hir::PatKind;
|
use rustc_hir::PatKind;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_middle::ty::Ty;
|
use rustc_middle::ty::Ty;
|
||||||
use rustc_middle::ty::UserType;
|
use rustc_middle::ty::UserType;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
@ -72,10 +72,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
|
|||||||
match ty_opt {
|
match ty_opt {
|
||||||
None => {
|
None => {
|
||||||
// Infer the variable's type.
|
// Infer the variable's type.
|
||||||
let var_ty = self.fcx.next_ty_var(TypeVariableOrigin {
|
let var_ty = self.fcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span });
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
|
||||||
span,
|
|
||||||
});
|
|
||||||
self.fcx.locals.borrow_mut().insert(nid, var_ty);
|
self.fcx.locals.borrow_mut().insert(nid, var_ty);
|
||||||
var_ty
|
var_ty
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ use rustc_hir::intravisit::{Map, Visitor};
|
|||||||
use rustc_hir::{HirIdMap, Node};
|
use rustc_hir::{HirIdMap, Node};
|
||||||
use rustc_hir_analysis::check::check_abi;
|
use rustc_hir_analysis::check::check_abi;
|
||||||
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::traits::{ObligationCauseCode, ObligationInspector, WellFormedLoc};
|
use rustc_infer::traits::{ObligationCauseCode, ObligationInspector, WellFormedLoc};
|
||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
use rustc_middle::traits;
|
use rustc_middle::traits;
|
||||||
@ -261,10 +261,7 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
|
|||||||
tcx.impl_trait_ref(item.container_id(tcx)).unwrap().instantiate_identity().args;
|
tcx.impl_trait_ref(item.container_id(tcx)).unwrap().instantiate_identity().args;
|
||||||
Some(tcx.type_of(trait_item).instantiate(tcx, args))
|
Some(tcx.type_of(trait_item).instantiate(tcx, args))
|
||||||
} else {
|
} else {
|
||||||
Some(fcx.next_ty_var(TypeVariableOrigin {
|
Some(fcx.next_ty_var(TypeVariableOrigin { span, param_def_id: None }))
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
|
||||||
span,
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
} else if let Node::AnonConst(_) = node {
|
} else if let Node::AnonConst(_) = node {
|
||||||
let id = tcx.local_def_id_to_hir_id(def_id);
|
let id = tcx.local_def_id_to_hir_id(def_id);
|
||||||
@ -272,10 +269,7 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
|
|||||||
Node::Ty(&hir::Ty { kind: hir::TyKind::Typeof(ref anon_const), span, .. })
|
Node::Ty(&hir::Ty { kind: hir::TyKind::Typeof(ref anon_const), span, .. })
|
||||||
if anon_const.hir_id == id =>
|
if anon_const.hir_id == id =>
|
||||||
{
|
{
|
||||||
Some(fcx.next_ty_var(TypeVariableOrigin {
|
Some(fcx.next_ty_var(TypeVariableOrigin { span, param_def_id: None }))
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
|
||||||
span,
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
Node::Expr(&hir::Expr { kind: hir::ExprKind::InlineAsm(asm), span, .. })
|
Node::Expr(&hir::Expr { kind: hir::ExprKind::InlineAsm(asm), span, .. })
|
||||||
| Node::Item(&hir::Item { kind: hir::ItemKind::GlobalAsm(asm), span, .. }) => {
|
| Node::Item(&hir::Item { kind: hir::ItemKind::GlobalAsm(asm), span, .. }) => {
|
||||||
@ -285,10 +279,7 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
|
|||||||
Some(fcx.next_int_var())
|
Some(fcx.next_int_var())
|
||||||
}
|
}
|
||||||
hir::InlineAsmOperand::SymFn { anon_const } if anon_const.hir_id == id => {
|
hir::InlineAsmOperand::SymFn { anon_const } if anon_const.hir_id == id => {
|
||||||
Some(fcx.next_ty_var(TypeVariableOrigin {
|
Some(fcx.next_ty_var(TypeVariableOrigin { span, param_def_id: None }))
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span,
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
@ -7,7 +7,7 @@ use hir::HirId;
|
|||||||
use hir::ItemKind;
|
use hir::ItemKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_middle::ty::{Adt, Array, Ref, Ty};
|
use rustc_middle::ty::{Adt, Array, Ref, Ty};
|
||||||
use rustc_session::lint::builtin::RUST_2021_PRELUDE_COLLISIONS;
|
use rustc_session::lint::builtin::RUST_2021_PRELUDE_COLLISIONS;
|
||||||
use rustc_span::symbol::kw::{Empty, Underscore};
|
use rustc_span::symbol::kw::{Empty, Underscore};
|
||||||
@ -218,10 +218,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// If we know it does not, we don't need to warn.
|
// If we know it does not, we don't need to warn.
|
||||||
if method_name.name == sym::from_iter {
|
if method_name.name == sym::from_iter {
|
||||||
if let Some(trait_def_id) = self.tcx.get_diagnostic_item(sym::FromIterator) {
|
if let Some(trait_def_id) = self.tcx.get_diagnostic_item(sym::FromIterator) {
|
||||||
let any_type = self.infcx.next_ty_var(TypeVariableOrigin {
|
let any_type =
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
self.infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span });
|
||||||
span,
|
|
||||||
});
|
|
||||||
if !self
|
if !self
|
||||||
.infcx
|
.infcx
|
||||||
.type_implements_trait(trait_def_id, [self_ty, any_type], self.param_env)
|
.type_implements_trait(trait_def_id, [self_ty, any_type], self.param_env)
|
||||||
|
@ -22,11 +22,7 @@ use rustc_hir::lang_items::LangItem;
|
|||||||
use rustc_hir::PatKind::Binding;
|
use rustc_hir::PatKind::Binding;
|
||||||
use rustc_hir::PathSegment;
|
use rustc_hir::PathSegment;
|
||||||
use rustc_hir::{ExprKind, Node, QPath};
|
use rustc_hir::{ExprKind, Node, QPath};
|
||||||
use rustc_infer::infer::{
|
use rustc_infer::infer::{self, type_variable::TypeVariableOrigin, RegionVariableOrigin};
|
||||||
self,
|
|
||||||
type_variable::{TypeVariableOrigin, TypeVariableOriginKind},
|
|
||||||
RegionVariableOrigin,
|
|
||||||
};
|
|
||||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||||
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
|
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
|
||||||
use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
|
use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
|
||||||
@ -82,13 +78,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let trait_ref = ty::TraitRef::new(
|
let trait_ref = ty::TraitRef::new(
|
||||||
tcx,
|
tcx,
|
||||||
fn_once,
|
fn_once,
|
||||||
[
|
[ty, self.next_ty_var(TypeVariableOrigin { param_def_id: None, span })],
|
||||||
ty,
|
|
||||||
self.next_ty_var(TypeVariableOrigin {
|
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
let poly_trait_ref = ty::Binder::dummy(trait_ref);
|
let poly_trait_ref = ty::Binder::dummy(trait_ref);
|
||||||
let obligation = Obligation::misc(
|
let obligation = Obligation::misc(
|
||||||
@ -1271,7 +1261,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
.map(|expr| {
|
.map(|expr| {
|
||||||
self.node_ty_opt(expr.hir_id).unwrap_or_else(|| {
|
self.node_ty_opt(expr.hir_id).unwrap_or_else(|| {
|
||||||
self.next_ty_var(TypeVariableOrigin {
|
self.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
param_def_id: None,
|
||||||
span: expr.span,
|
span: expr.span,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -1861,7 +1851,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
GenericArgKind::Type(_) => self
|
GenericArgKind::Type(_) => self
|
||||||
.next_ty_var(TypeVariableOrigin {
|
.next_ty_var(TypeVariableOrigin {
|
||||||
span: rustc_span::DUMMY_SP,
|
span: rustc_span::DUMMY_SP,
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
param_def_id: None,
|
||||||
})
|
})
|
||||||
.into(),
|
.into(),
|
||||||
GenericArgKind::Const(arg) => self
|
GenericArgKind::Const(arg) => self
|
||||||
|
@ -7,7 +7,7 @@ use rustc_ast as ast;
|
|||||||
use rustc_data_structures::packed::Pu128;
|
use rustc_data_structures::packed::Pu128;
|
||||||
use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag};
|
use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::traits::ObligationCauseCode;
|
use rustc_infer::traits::ObligationCauseCode;
|
||||||
use rustc_middle::ty::adjustment::{
|
use rustc_middle::ty::adjustment::{
|
||||||
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
|
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
|
||||||
@ -219,10 +219,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// e.g., adding `&'a T` and `&'b T`, given `&'x T: Add<&'x T>`, will result
|
// e.g., adding `&'a T` and `&'b T`, given `&'x T: Add<&'x T>`, will result
|
||||||
// in `&'a T <: &'x T` and `&'b T <: &'x T`, instead of `'a = 'b = 'x`.
|
// in `&'a T <: &'x T` and `&'b T <: &'x T`, instead of `'a = 'b = 'x`.
|
||||||
let lhs_ty = self.check_expr(lhs_expr);
|
let lhs_ty = self.check_expr(lhs_expr);
|
||||||
let fresh_var = self.next_ty_var(TypeVariableOrigin {
|
let fresh_var = self
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: lhs_expr.span });
|
||||||
span: lhs_expr.span,
|
|
||||||
});
|
|
||||||
self.demand_coerce(lhs_expr, lhs_ty, fresh_var, Some(rhs_expr), AllowTwoPhase::No)
|
self.demand_coerce(lhs_expr, lhs_ty, fresh_var, Some(rhs_expr), AllowTwoPhase::No)
|
||||||
}
|
}
|
||||||
IsAssign::Yes => {
|
IsAssign::Yes => {
|
||||||
@ -241,10 +239,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// using this variable as the expected type, which sometimes lets
|
// using this variable as the expected type, which sometimes lets
|
||||||
// us do better coercions than we would be able to do otherwise,
|
// us do better coercions than we would be able to do otherwise,
|
||||||
// particularly for things like `String + &String`.
|
// particularly for things like `String + &String`.
|
||||||
let rhs_ty_var = self.next_ty_var(TypeVariableOrigin {
|
let rhs_ty_var =
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: rhs_expr.span });
|
||||||
span: rhs_expr.span,
|
|
||||||
});
|
|
||||||
|
|
||||||
let result = self.lookup_op_method(
|
let result = self.lookup_op_method(
|
||||||
(lhs_expr, lhs_ty),
|
(lhs_expr, lhs_ty),
|
||||||
|
@ -9,7 +9,7 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
|
|||||||
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
|
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
|
||||||
use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability, Pat, PatKind};
|
use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability, Pat, PatKind};
|
||||||
use rustc_infer::infer;
|
use rustc_infer::infer;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_middle::mir::interpret::ErrorHandled;
|
use rustc_middle::mir::interpret::ErrorHandled;
|
||||||
use rustc_middle::ty::{self, Adt, Ty, TypeVisitableExt};
|
use rustc_middle::ty::{self, Adt, Ty, TypeVisitableExt};
|
||||||
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
|
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
|
||||||
@ -1369,7 +1369,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
self.next_ty_var(
|
self.next_ty_var(
|
||||||
// FIXME: `MiscVariable` for now -- obtaining the span and name information
|
// FIXME: `MiscVariable` for now -- obtaining the span and name information
|
||||||
// from all tuple elements isn't trivial.
|
// from all tuple elements isn't trivial.
|
||||||
TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span },
|
TypeVariableOrigin { param_def_id: None, span },
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let element_tys = tcx.mk_type_list_from_iter(element_tys_iter);
|
let element_tys = tcx.mk_type_list_from_iter(element_tys_iter);
|
||||||
@ -1997,10 +1997,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
// Here, `demand::subtype` is good enough, but I don't
|
// Here, `demand::subtype` is good enough, but I don't
|
||||||
// think any errors can be introduced by using `demand::eqtype`.
|
// think any errors can be introduced by using `demand::eqtype`.
|
||||||
let inner_ty = self.next_ty_var(TypeVariableOrigin {
|
let inner_ty =
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: inner.span });
|
||||||
span: inner.span,
|
|
||||||
});
|
|
||||||
let box_ty = Ty::new_box(tcx, inner_ty);
|
let box_ty = Ty::new_box(tcx, inner_ty);
|
||||||
self.demand_eqtype_pat(span, expected, box_ty, pat_info.top_info);
|
self.demand_eqtype_pat(span, expected, box_ty, pat_info.top_info);
|
||||||
(box_ty, inner_ty)
|
(box_ty, inner_ty)
|
||||||
@ -2088,7 +2086,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
(expected, expected)
|
(expected, expected)
|
||||||
} else {
|
} else {
|
||||||
let inner_ty = self.next_ty_var(TypeVariableOrigin {
|
let inner_ty = self.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
param_def_id: None,
|
||||||
span: inner.span,
|
span: inner.span,
|
||||||
});
|
});
|
||||||
let ref_ty = self.new_ref_ty(pat.span, mutbl, inner_ty);
|
let ref_ty = self.new_ref_ty(pat.span, mutbl, inner_ty);
|
||||||
@ -2138,8 +2136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let len = before.len();
|
let len = before.len();
|
||||||
let ty_var_origin =
|
let ty_var_origin = TypeVariableOrigin { param_def_id: None, span };
|
||||||
TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span };
|
|
||||||
let inner_ty = self.next_ty_var(ty_var_origin);
|
let inner_ty = self.next_ty_var(ty_var_origin);
|
||||||
|
|
||||||
Some(Ty::new_array(tcx, inner_ty, len.try_into().unwrap()))
|
Some(Ty::new_array(tcx, inner_ty, len.try_into().unwrap()))
|
||||||
|
@ -4,7 +4,7 @@ use rustc_ast as ast;
|
|||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir_analysis::autoderef::Autoderef;
|
use rustc_hir_analysis::autoderef::Autoderef;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::InferOk;
|
use rustc_infer::infer::InferOk;
|
||||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref, PointerCoercion};
|
use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref, PointerCoercion};
|
||||||
use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
|
use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
|
||||||
@ -147,10 +147,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// If some lookup succeeds, write callee into table and extract index/element
|
// If some lookup succeeds, write callee into table and extract index/element
|
||||||
// type from the method signature.
|
// type from the method signature.
|
||||||
// If some lookup succeeded, install method in table
|
// If some lookup succeeded, install method in table
|
||||||
let input_ty = self.next_ty_var(TypeVariableOrigin {
|
let input_ty =
|
||||||
kind: TypeVariableOriginKind::AutoDeref,
|
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: base_expr.span });
|
||||||
span: base_expr.span,
|
|
||||||
});
|
|
||||||
let method =
|
let method =
|
||||||
self.try_overloaded_place_op(expr.span, self_ty, &[input_ty], PlaceOp::Index);
|
self.try_overloaded_place_op(expr.span, self_ty, &[input_ty], PlaceOp::Index);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
|
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
|
||||||
|
|
||||||
use crate::infer::{ConstVariableOrigin, ConstVariableOriginKind};
|
use crate::infer::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||||
use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin, TypeVariableOriginKind};
|
use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin};
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
use rustc_middle::infer::unify_key::EffectVarValue;
|
use rustc_middle::infer::unify_key::EffectVarValue;
|
||||||
use rustc_middle::ty::fold::TypeFoldable;
|
use rustc_middle::ty::fold::TypeFoldable;
|
||||||
@ -115,7 +115,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
CanonicalVarKind::Ty(ty_kind) => {
|
CanonicalVarKind::Ty(ty_kind) => {
|
||||||
let ty = match ty_kind {
|
let ty = match ty_kind {
|
||||||
CanonicalTyVarKind::General(ui) => self.next_ty_var_in_universe(
|
CanonicalTyVarKind::General(ui) => self.next_ty_var_in_universe(
|
||||||
TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span },
|
TypeVariableOrigin { param_def_id: None, span },
|
||||||
universe_map(ui),
|
universe_map(ui),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ use crate::errors::{
|
|||||||
SourceKindMultiSuggestion, SourceKindSubdiag,
|
SourceKindMultiSuggestion, SourceKindSubdiag,
|
||||||
};
|
};
|
||||||
use crate::infer::error_reporting::TypeErrCtxt;
|
use crate::infer::error_reporting::TypeErrCtxt;
|
||||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use crate::infer::type_variable::TypeVariableOrigin;
|
||||||
use crate::infer::InferCtxt;
|
use crate::infer::InferCtxt;
|
||||||
use rustc_errors::{codes::*, Diag, IntoDiagArg};
|
use rustc_errors::{codes::*, Diag, IntoDiagArg};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
@ -188,7 +188,8 @@ fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinte
|
|||||||
let mut infcx_inner = infcx.inner.borrow_mut();
|
let mut infcx_inner = infcx.inner.borrow_mut();
|
||||||
let ty_vars = infcx_inner.type_variables();
|
let ty_vars = infcx_inner.type_variables();
|
||||||
let var_origin = ty_vars.var_origin(ty_vid);
|
let var_origin = ty_vars.var_origin(ty_vid);
|
||||||
if let TypeVariableOriginKind::TypeParameterDefinition(name, def_id) = var_origin.kind
|
if let Some(def_id) = var_origin.param_def_id
|
||||||
|
&& let name = infcx.tcx.item_name(def_id)
|
||||||
&& name != kw::SelfUpper
|
&& name != kw::SelfUpper
|
||||||
&& !var_origin.span.from_expansion()
|
&& !var_origin.span.from_expansion()
|
||||||
{
|
{
|
||||||
@ -302,9 +303,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
let mut inner = self.inner.borrow_mut();
|
let mut inner = self.inner.borrow_mut();
|
||||||
let ty_vars = &inner.type_variables();
|
let ty_vars = &inner.type_variables();
|
||||||
let var_origin = ty_vars.var_origin(ty_vid);
|
let var_origin = ty_vars.var_origin(ty_vid);
|
||||||
if let TypeVariableOriginKind::TypeParameterDefinition(name, def_id) =
|
if let Some(def_id) = var_origin.param_def_id {
|
||||||
var_origin.kind
|
let name = self.tcx.item_name(def_id);
|
||||||
{
|
|
||||||
if name != kw::SelfUpper && !var_origin.span.from_expansion() {
|
if name != kw::SelfUpper && !var_origin.span.from_expansion() {
|
||||||
return InferenceDiagnosticsData {
|
return InferenceDiagnosticsData {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
@ -549,7 +549,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
GenericArgKind::Type(_) => self
|
GenericArgKind::Type(_) => self
|
||||||
.next_ty_var(TypeVariableOrigin {
|
.next_ty_var(TypeVariableOrigin {
|
||||||
span: DUMMY_SP,
|
span: DUMMY_SP,
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
param_def_id: None,
|
||||||
})
|
})
|
||||||
.into(),
|
.into(),
|
||||||
GenericArgKind::Const(arg) => self
|
GenericArgKind::Const(arg) => self
|
||||||
@ -576,10 +576,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
InferSourceKind::FullyQualifiedMethodCall { receiver, successor, args, def_id } => {
|
InferSourceKind::FullyQualifiedMethodCall { receiver, successor, args, def_id } => {
|
||||||
let placeholder = Some(self.next_ty_var(TypeVariableOrigin {
|
let placeholder = Some(
|
||||||
span: DUMMY_SP,
|
self.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
);
|
||||||
}));
|
|
||||||
if let Some(args) = args.make_suggestable(self.infcx.tcx, true, placeholder) {
|
if let Some(args) = args.make_suggestable(self.infcx.tcx, true, placeholder) {
|
||||||
let mut printer = fmt_printer(self, Namespace::ValueNS);
|
let mut printer = fmt_printer(self, Namespace::ValueNS);
|
||||||
printer.print_def_path(def_id, args).unwrap();
|
printer.print_def_path(def_id, args).unwrap();
|
||||||
@ -613,10 +612,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
InferSourceKind::ClosureReturn { ty, data, should_wrap_expr } => {
|
InferSourceKind::ClosureReturn { ty, data, should_wrap_expr } => {
|
||||||
let placeholder = Some(self.next_ty_var(TypeVariableOrigin {
|
let placeholder = Some(
|
||||||
span: DUMMY_SP,
|
self.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
);
|
||||||
}));
|
|
||||||
if let Some(ty) = ty.make_suggestable(self.infcx.tcx, true, placeholder) {
|
if let Some(ty) = ty.make_suggestable(self.infcx.tcx, true, placeholder) {
|
||||||
let ty_info = ty_to_string(self, ty, None);
|
let ty_info = ty_to_string(self, ty, None);
|
||||||
multi_suggestions.push(SourceKindMultiSuggestion::new_closure_return(
|
multi_suggestions.push(SourceKindMultiSuggestion::new_closure_return(
|
||||||
|
@ -48,7 +48,7 @@ use rustc_span::Span;
|
|||||||
use snapshot::undo_log::InferCtxtUndoLogs;
|
use snapshot::undo_log::InferCtxtUndoLogs;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use type_variable::TypeVariableOrigin;
|
||||||
|
|
||||||
pub mod at;
|
pub mod at;
|
||||||
pub mod canonical;
|
pub mod canonical;
|
||||||
@ -1111,13 +1111,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
// as the generic parameters for the default, `(T, U)`.
|
// as the generic parameters for the default, `(T, U)`.
|
||||||
let ty_var_id = self.inner.borrow_mut().type_variables().new_var(
|
let ty_var_id = self.inner.borrow_mut().type_variables().new_var(
|
||||||
self.universe(),
|
self.universe(),
|
||||||
TypeVariableOrigin {
|
TypeVariableOrigin { param_def_id: Some(param.def_id), span },
|
||||||
kind: TypeVariableOriginKind::TypeParameterDefinition(
|
|
||||||
param.name,
|
|
||||||
param.def_id,
|
|
||||||
),
|
|
||||||
span,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Ty::new_var(self.tcx, ty_var_id).into()
|
Ty::new_var(self.tcx, ty_var_id).into()
|
||||||
@ -1411,10 +1405,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
.entry(bt.var)
|
.entry(bt.var)
|
||||||
.or_insert_with(|| {
|
.or_insert_with(|| {
|
||||||
self.infcx
|
self.infcx
|
||||||
.next_ty_var(TypeVariableOrigin {
|
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.span })
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: self.span,
|
|
||||||
})
|
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
.expect_ty()
|
.expect_ty()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use super::type_variable::TypeVariableOrigin;
|
||||||
use super::{DefineOpaqueTypes, InferResult};
|
use super::{DefineOpaqueTypes, InferResult};
|
||||||
use crate::errors::OpaqueHiddenTypeDiag;
|
use crate::errors::OpaqueHiddenTypeDiag;
|
||||||
use crate::infer::{InferCtxt, InferOk};
|
use crate::infer::{InferCtxt, InferOk};
|
||||||
@ -68,10 +68,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
// FIXME(compiler-errors): We probably should add a new TypeVariableOriginKind
|
// FIXME(compiler-errors): We probably should add a new TypeVariableOriginKind
|
||||||
// for opaque types, and then use that kind to fix the spans for type errors
|
// for opaque types, and then use that kind to fix the spans for type errors
|
||||||
// that we see later on.
|
// that we see later on.
|
||||||
let ty_var = self.next_ty_var(TypeVariableOrigin {
|
let ty_var = self.next_ty_var(TypeVariableOrigin { param_def_id: None, span });
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span,
|
|
||||||
});
|
|
||||||
obligations.extend(
|
obligations.extend(
|
||||||
self.handle_opaque_type(ty, ty_var, &cause, param_env).unwrap().obligations,
|
self.handle_opaque_type(ty, ty_var, &cause, param_env).unwrap().obligations,
|
||||||
);
|
);
|
||||||
|
@ -3,7 +3,7 @@ use rustc_middle::ty::{self, Ty};
|
|||||||
|
|
||||||
use crate::traits::{Obligation, PredicateObligation};
|
use crate::traits::{Obligation, PredicateObligation};
|
||||||
|
|
||||||
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use super::type_variable::TypeVariableOrigin;
|
||||||
use super::InferCtxt;
|
use super::InferCtxt;
|
||||||
|
|
||||||
impl<'tcx> InferCtxt<'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
@ -24,7 +24,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
debug_assert!(!self.next_trait_solver());
|
debug_assert!(!self.next_trait_solver());
|
||||||
let def_id = projection_ty.def_id;
|
let def_id = projection_ty.def_id;
|
||||||
let ty_var = self.next_ty_var(TypeVariableOrigin {
|
let ty_var = self.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::NormalizeProjectionType,
|
param_def_id: None,
|
||||||
span: self.tcx.def_span(def_id),
|
span: self.tcx.def_span(def_id),
|
||||||
});
|
});
|
||||||
let projection = ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Projection(
|
let projection = ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Projection(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use super::StructurallyRelateAliases;
|
use super::StructurallyRelateAliases;
|
||||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind, TypeVariableValue};
|
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableValue};
|
||||||
use crate::infer::{InferCtxt, ObligationEmittingRelation, RegionVariableOrigin};
|
use crate::infer::{InferCtxt, ObligationEmittingRelation, RegionVariableOrigin};
|
||||||
use rustc_data_structures::sso::SsoHashMap;
|
use rustc_data_structures::sso::SsoHashMap;
|
||||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||||
@ -352,7 +352,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
|
|||||||
) -> Result<Ty<'tcx>, TypeError<'tcx>> {
|
) -> Result<Ty<'tcx>, TypeError<'tcx>> {
|
||||||
if self.infcx.next_trait_solver() && !alias.has_escaping_bound_vars() {
|
if self.infcx.next_trait_solver() && !alias.has_escaping_bound_vars() {
|
||||||
return Ok(self.infcx.next_ty_var_in_universe(
|
return Ok(self.infcx.next_ty_var_in_universe(
|
||||||
TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span: self.span },
|
TypeVariableOrigin { param_def_id: None, span: self.span },
|
||||||
self.for_universe,
|
self.for_universe,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -375,10 +375,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
|
|||||||
|
|
||||||
debug!("generalization failure in alias");
|
debug!("generalization failure in alias");
|
||||||
Ok(self.infcx.next_ty_var_in_universe(
|
Ok(self.infcx.next_ty_var_in_universe(
|
||||||
TypeVariableOrigin {
|
TypeVariableOrigin { param_def_id: None, span: self.span },
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: self.span,
|
|
||||||
},
|
|
||||||
self.for_universe,
|
self.for_universe,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
|
//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
|
||||||
|
|
||||||
use super::combine::ObligationEmittingRelation;
|
use super::combine::ObligationEmittingRelation;
|
||||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use crate::infer::type_variable::TypeVariableOrigin;
|
||||||
use crate::infer::{DefineOpaqueTypes, InferCtxt};
|
use crate::infer::{DefineOpaqueTypes, InferCtxt};
|
||||||
use crate::traits::ObligationCause;
|
use crate::traits::ObligationCause;
|
||||||
|
|
||||||
@ -88,18 +88,14 @@ where
|
|||||||
// iterate on the subtype obligations that are returned, but I
|
// iterate on the subtype obligations that are returned, but I
|
||||||
// think this suffices. -nmatsakis
|
// think this suffices. -nmatsakis
|
||||||
(&ty::Infer(TyVar(..)), _) => {
|
(&ty::Infer(TyVar(..)), _) => {
|
||||||
let v = infcx.next_ty_var(TypeVariableOrigin {
|
let v = infcx
|
||||||
kind: TypeVariableOriginKind::LatticeVariable,
|
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: this.cause().span });
|
||||||
span: this.cause().span,
|
|
||||||
});
|
|
||||||
this.relate_bound(v, b, a)?;
|
this.relate_bound(v, b, a)?;
|
||||||
Ok(v)
|
Ok(v)
|
||||||
}
|
}
|
||||||
(_, &ty::Infer(TyVar(..))) => {
|
(_, &ty::Infer(TyVar(..))) => {
|
||||||
let v = infcx.next_ty_var(TypeVariableOrigin {
|
let v = infcx
|
||||||
kind: TypeVariableOriginKind::LatticeVariable,
|
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: this.cause().span });
|
||||||
span: this.cause().span,
|
|
||||||
});
|
|
||||||
this.relate_bound(v, a, b)?;
|
this.relate_bound(v, a, b)?;
|
||||||
Ok(v)
|
Ok(v)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ use rustc_data_structures::undo_log::Rollback;
|
|||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
use rustc_middle::ty::{self, Ty, TyVid};
|
use rustc_middle::ty::{self, Ty, TyVid};
|
||||||
use rustc_span::symbol::Symbol;
|
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
use crate::infer::InferCtxtUndoLogs;
|
use crate::infer::InferCtxtUndoLogs;
|
||||||
@ -37,30 +36,9 @@ pub struct TypeVariableTable<'a, 'tcx> {
|
|||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct TypeVariableOrigin {
|
pub struct TypeVariableOrigin {
|
||||||
pub kind: TypeVariableOriginKind,
|
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
// `DefId` of the type parameter this was instantiated for, if any.
|
||||||
|
pub param_def_id: Option<DefId>,
|
||||||
/// Reasons to create a type inference variable
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
|
||||||
pub enum TypeVariableOriginKind {
|
|
||||||
MiscVariable,
|
|
||||||
NormalizeProjectionType,
|
|
||||||
TypeInference,
|
|
||||||
TypeParameterDefinition(Symbol, DefId),
|
|
||||||
|
|
||||||
/// One of the upvars or closure kind parameters in a `ClosureArgs`
|
|
||||||
/// (before it has been determined).
|
|
||||||
// FIXME(eddyb) distinguish upvar inference variables from the rest.
|
|
||||||
ClosureSynthetic,
|
|
||||||
AutoDeref,
|
|
||||||
AdjustmentType,
|
|
||||||
|
|
||||||
/// In type check, when we are type checking a function that
|
|
||||||
/// returns `-> dyn Foo`, we instantiate a type variable with the
|
|
||||||
/// return type for diagnostic purposes.
|
|
||||||
DynReturnFn,
|
|
||||||
LatticeVariable,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -2,7 +2,7 @@ use crate::build::expr::as_place::{PlaceBase, PlaceBuilder};
|
|||||||
use crate::build::matches::{Binding, Candidate, FlatPat, MatchPair, TestCase};
|
use crate::build::matches::{Binding, Candidate, FlatPat, MatchPair, TestCase};
|
||||||
use crate::build::Builder;
|
use crate::build::Builder;
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::thir::{self, *};
|
use rustc_middle::thir::{self, *};
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
@ -178,10 +178,9 @@ impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
|
|||||||
cx.tcx,
|
cx.tcx,
|
||||||
ty::InlineConstArgsParts {
|
ty::InlineConstArgsParts {
|
||||||
parent_args: ty::GenericArgs::identity_for_item(cx.tcx, parent_id),
|
parent_args: ty::GenericArgs::identity_for_item(cx.tcx, parent_id),
|
||||||
ty: cx.infcx.next_ty_var(TypeVariableOrigin {
|
ty: cx
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
.infcx
|
||||||
span,
|
.next_ty_var(TypeVariableOrigin { param_def_id: None, span }),
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.args;
|
.args;
|
||||||
|
@ -2,7 +2,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
|
|||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_infer::infer::at::ToTrace;
|
use rustc_infer::infer::at::ToTrace;
|
||||||
use rustc_infer::infer::canonical::CanonicalVarValues;
|
use rustc_infer::infer::canonical::CanonicalVarValues;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::{
|
use rustc_infer::infer::{
|
||||||
BoundRegionConversionTime, DefineOpaqueTypes, InferCtxt, InferOk, TyCtxtInferExt,
|
BoundRegionConversionTime, DefineOpaqueTypes, InferCtxt, InferOk, TyCtxtInferExt,
|
||||||
};
|
};
|
||||||
@ -587,10 +587,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn next_ty_infer(&self) -> Ty<'tcx> {
|
pub(super) fn next_ty_infer(&self) -> Ty<'tcx> {
|
||||||
self.infcx.next_ty_var(TypeVariableOrigin {
|
self.infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: DUMMY_SP })
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: DUMMY_SP,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn next_const_infer(&self, ty: Ty<'tcx>) -> ty::Const<'tcx> {
|
pub(super) fn next_const_infer(&self, ty: Ty<'tcx>) -> ty::Const<'tcx> {
|
||||||
|
@ -3,7 +3,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
|||||||
use crate::traits::{BoundVarReplacer, PlaceholderReplacer};
|
use crate::traits::{BoundVarReplacer, PlaceholderReplacer};
|
||||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||||
use rustc_infer::infer::at::At;
|
use rustc_infer::infer::at::At;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::InferCtxt;
|
use rustc_infer::infer::InferCtxt;
|
||||||
use rustc_infer::traits::TraitEngineExt;
|
use rustc_infer::traits::TraitEngineExt;
|
||||||
use rustc_infer::traits::{FulfillmentError, Obligation, TraitEngine};
|
use rustc_infer::traits::{FulfillmentError, Obligation, TraitEngine};
|
||||||
@ -74,10 +74,8 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
|
|||||||
|
|
||||||
self.depth += 1;
|
self.depth += 1;
|
||||||
|
|
||||||
let new_infer_ty = infcx.next_ty_var(TypeVariableOrigin {
|
let new_infer_ty =
|
||||||
kind: TypeVariableOriginKind::NormalizeProjectionType,
|
infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.at.cause.span });
|
||||||
span: self.at.cause.span,
|
|
||||||
});
|
|
||||||
let obligation = Obligation::new(
|
let obligation = Obligation::new(
|
||||||
tcx,
|
tcx,
|
||||||
self.at.cause.clone(),
|
self.at.cause.clone(),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use crate::infer::type_variable::TypeVariableOrigin;
|
||||||
use crate::infer::InferCtxt;
|
use crate::infer::InferCtxt;
|
||||||
use crate::traits::{Obligation, ObligationCause, ObligationCtxt};
|
use crate::traits::{Obligation, ObligationCause, ObligationCtxt};
|
||||||
use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, Diag};
|
use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, Diag};
|
||||||
@ -217,10 +217,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
let Some(trait_def_id) = trait_def_id else { continue };
|
let Some(trait_def_id) = trait_def_id else { continue };
|
||||||
// Make a fresh inference variable so we can determine what the generic parameters
|
// Make a fresh inference variable so we can determine what the generic parameters
|
||||||
// of the trait are.
|
// of the trait are.
|
||||||
let var = self.next_ty_var(TypeVariableOrigin {
|
let var =
|
||||||
span: DUMMY_SP,
|
self.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None });
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
});
|
|
||||||
// FIXME(effects)
|
// FIXME(effects)
|
||||||
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, [ty.skip_binder(), var]);
|
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, [ty.skip_binder(), var]);
|
||||||
let obligation = Obligation::new(
|
let obligation = Obligation::new(
|
||||||
|
@ -24,7 +24,7 @@ use rustc_hir::is_range_literal;
|
|||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node};
|
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node};
|
||||||
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk};
|
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk};
|
||||||
use rustc_middle::hir::map;
|
use rustc_middle::hir::map;
|
||||||
use rustc_middle::traits::IsConstable;
|
use rustc_middle::traits::IsConstable;
|
||||||
@ -1894,10 +1894,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
ty::Tuple(inputs) if infcx.tcx.is_fn_trait(trait_ref.def_id()) => {
|
ty::Tuple(inputs) if infcx.tcx.is_fn_trait(trait_ref.def_id()) => {
|
||||||
infcx.tcx.mk_fn_sig(
|
infcx.tcx.mk_fn_sig(
|
||||||
*inputs,
|
*inputs,
|
||||||
infcx.next_ty_var(TypeVariableOrigin {
|
infcx
|
||||||
span: DUMMY_SP,
|
.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
}),
|
|
||||||
false,
|
false,
|
||||||
hir::Unsafety::Normal,
|
hir::Unsafety::Normal,
|
||||||
abi::Abi::Rust,
|
abi::Abi::Rust,
|
||||||
@ -1905,10 +1903,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
_ => infcx.tcx.mk_fn_sig(
|
_ => infcx.tcx.mk_fn_sig(
|
||||||
[inputs],
|
[inputs],
|
||||||
infcx.next_ty_var(TypeVariableOrigin {
|
infcx.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
|
||||||
span: DUMMY_SP,
|
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
}),
|
|
||||||
false,
|
false,
|
||||||
hir::Unsafety::Normal,
|
hir::Unsafety::Normal,
|
||||||
abi::Abi::Rust,
|
abi::Abi::Rust,
|
||||||
@ -4269,7 +4264,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let origin = TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span };
|
let origin = TypeVariableOrigin { param_def_id: None, span };
|
||||||
// Make `Self` be equivalent to the type of the call chain
|
// Make `Self` be equivalent to the type of the call chain
|
||||||
// expression we're looking at now, so that we can tell what
|
// expression we're looking at now, so that we can tell what
|
||||||
// for example `Iterator::Item` is at this point in the chain.
|
// for example `Iterator::Item` is at this point in the chain.
|
||||||
|
@ -6,7 +6,7 @@ use crate::errors::{
|
|||||||
AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch,
|
AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch,
|
||||||
};
|
};
|
||||||
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
|
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
|
||||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use crate::infer::type_variable::TypeVariableOrigin;
|
||||||
use crate::infer::InferCtxtExt as _;
|
use crate::infer::InferCtxtExt as _;
|
||||||
use crate::infer::{self, InferCtxt};
|
use crate::infer::{self, InferCtxt};
|
||||||
use crate::traits::error_reporting::infer_ctxt_ext::InferCtxtExt;
|
use crate::traits::error_reporting::infer_ctxt_ext::InferCtxtExt;
|
||||||
@ -2820,10 +2820,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
if let ty::Param(_) = *ty.kind() {
|
if let ty::Param(_) = *ty.kind() {
|
||||||
let infcx = self.infcx;
|
let infcx = self.infcx;
|
||||||
*self.var_map.entry(ty).or_insert_with(|| {
|
*self.var_map.entry(ty).or_insert_with(|| {
|
||||||
infcx.next_ty_var(TypeVariableOrigin {
|
infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: DUMMY_SP })
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: DUMMY_SP,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
ty.super_fold_with(self)
|
ty.super_fold_with(self)
|
||||||
|
@ -18,7 +18,7 @@ use rustc_middle::traits::ImplSource;
|
|||||||
use rustc_middle::traits::ImplSourceUserDefinedData;
|
use rustc_middle::traits::ImplSourceUserDefinedData;
|
||||||
|
|
||||||
use crate::errors::InherentProjectionNormalizationOverflow;
|
use crate::errors::InherentProjectionNormalizationOverflow;
|
||||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use crate::infer::type_variable::TypeVariableOrigin;
|
||||||
use crate::infer::{BoundRegionConversionTime, InferOk};
|
use crate::infer::{BoundRegionConversionTime, InferOk};
|
||||||
use crate::traits::normalize::normalize_with_depth;
|
use crate::traits::normalize::normalize_with_depth;
|
||||||
use crate::traits::normalize::normalize_with_depth_to;
|
use crate::traits::normalize::normalize_with_depth_to;
|
||||||
@ -522,7 +522,7 @@ fn normalize_to_error<'a, 'tcx>(
|
|||||||
};
|
};
|
||||||
let tcx = selcx.infcx.tcx;
|
let tcx = selcx.infcx.tcx;
|
||||||
let new_value = selcx.infcx.next_ty_var(TypeVariableOrigin {
|
let new_value = selcx.infcx.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::NormalizeProjectionType,
|
param_def_id: None,
|
||||||
span: tcx.def_span(projection_ty.def_id),
|
span: tcx.def_span(projection_ty.def_id),
|
||||||
});
|
});
|
||||||
Normalized { value: new_value, obligations: vec![trait_obligation] }
|
Normalized { value: new_value, obligations: vec![trait_obligation] }
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use rustc_infer::infer::at::At;
|
use rustc_infer::infer::at::At;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||||
use rustc_infer::traits::{FulfillmentError, TraitEngine};
|
use rustc_infer::traits::{FulfillmentError, TraitEngine};
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
|
|
||||||
@ -19,10 +19,9 @@ impl<'tcx> At<'_, 'tcx> {
|
|||||||
return Ok(ty);
|
return Ok(ty);
|
||||||
};
|
};
|
||||||
|
|
||||||
let new_infer_ty = self.infcx.next_ty_var(TypeVariableOrigin {
|
let new_infer_ty = self
|
||||||
kind: TypeVariableOriginKind::NormalizeProjectionType,
|
.infcx
|
||||||
span: self.cause.span,
|
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.cause.span });
|
||||||
});
|
|
||||||
|
|
||||||
// We simply emit an `alias-eq` goal here, since that will take care of
|
// We simply emit an `alias-eq` goal here, since that will take care of
|
||||||
// normalizing the LHS of the projection until it is a rigid projection
|
// normalizing the LHS of the projection until it is a rigid projection
|
||||||
|
@ -10,7 +10,7 @@ use rustc_hir as hir;
|
|||||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::{Expr, FnDecl, LangItem, TyKind, Unsafety};
|
use rustc_hir::{Expr, FnDecl, LangItem, TyKind, Unsafety};
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::{TypeVariableOrigin};
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::mir::interpret::Scalar;
|
use rustc_middle::mir::interpret::Scalar;
|
||||||
@ -276,8 +276,8 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
|
|||||||
.map(|arg| {
|
.map(|arg| {
|
||||||
arg.into().unwrap_or_else(|| {
|
arg.into().unwrap_or_else(|| {
|
||||||
let orig = TypeVariableOrigin {
|
let orig = TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: DUMMY_SP,
|
span: DUMMY_SP,
|
||||||
|
param_def_id: None,
|
||||||
};
|
};
|
||||||
infcx.next_ty_var(orig).into()
|
infcx.next_ty_var(orig).into()
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user