rename instantiate_canonical_with_fresh_inference_vars
This commit is contained in:
parent
8124b26122
commit
e34e344118
6 changed files with 11 additions and 16 deletions
|
@ -61,7 +61,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn instantiate_canonical_with_fresh_inference_vars<T>(
|
pub(super) fn instantiate_canonical<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
span: Span,
|
span: Span,
|
||||||
canonical: &Canonical<'tcx, T>,
|
canonical: &Canonical<'tcx, T>,
|
||||||
|
@ -69,8 +69,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
where
|
where
|
||||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
let (instantiated, _) =
|
let (instantiated, _) = self.infcx.instantiate_canonical(span, canonical);
|
||||||
self.infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical);
|
|
||||||
instantiated
|
instantiated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
// (e.g., the `_` in the code above) with fresh variables.
|
// (e.g., the `_` in the code above) with fresh variables.
|
||||||
// Then replace the bound items in the fn sig with fresh variables,
|
// Then replace the bound items in the fn sig with fresh variables,
|
||||||
// so that they represent the view from "inside" the closure.
|
// so that they represent the view from "inside" the closure.
|
||||||
let user_provided_sig = self
|
let user_provided_sig = self.instantiate_canonical(body.span, &user_provided_poly_sig);
|
||||||
.instantiate_canonical_with_fresh_inference_vars(body.span, &user_provided_poly_sig);
|
|
||||||
let mut user_provided_sig = self.infcx.instantiate_binder_with_fresh_vars(
|
let mut user_provided_sig = self.infcx.instantiate_binder_with_fresh_vars(
|
||||||
body.span,
|
body.span,
|
||||||
BoundRegionConversionTime::FnCall,
|
BoundRegionConversionTime::FnCall,
|
||||||
|
|
|
@ -1109,7 +1109,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
for user_annotation in self.user_type_annotations {
|
for user_annotation in self.user_type_annotations {
|
||||||
let CanonicalUserTypeAnnotation { span, ref user_ty, inferred_ty } = *user_annotation;
|
let CanonicalUserTypeAnnotation { span, ref user_ty, inferred_ty } = *user_annotation;
|
||||||
let annotation = self.instantiate_canonical_with_fresh_inference_vars(span, user_ty);
|
let annotation = self.instantiate_canonical(span, user_ty);
|
||||||
if let ty::UserType::TypeOf(def, args) = annotation
|
if let ty::UserType::TypeOf(def, args) = annotation
|
||||||
&& let DefKind::InlineConst = tcx.def_kind(def)
|
&& let DefKind::InlineConst = tcx.def_kind(def)
|
||||||
{
|
{
|
||||||
|
|
|
@ -386,10 +386,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let infcx = &self.infcx;
|
let infcx = &self.infcx;
|
||||||
let (ParamEnvAnd { param_env: _, value: self_ty }, canonical_inference_vars) =
|
let (ParamEnvAnd { param_env: _, value: self_ty }, canonical_inference_vars) =
|
||||||
infcx.instantiate_canonical_with_fresh_inference_vars(
|
infcx.instantiate_canonical(span, ¶m_env_and_self_ty);
|
||||||
span,
|
|
||||||
¶m_env_and_self_ty,
|
|
||||||
);
|
|
||||||
debug!(
|
debug!(
|
||||||
"probe_op: Mode::Path, param_env_and_self_ty={:?} self_ty={:?}",
|
"probe_op: Mode::Path, param_env_and_self_ty={:?} self_ty={:?}",
|
||||||
param_env_and_self_ty, self_ty
|
param_env_and_self_ty, self_ty
|
||||||
|
@ -661,13 +658,13 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
// of the iterations in the autoderef loop, so there is no problem with it
|
// of the iterations in the autoderef loop, so there is no problem with it
|
||||||
// being discoverable in another one of these iterations.
|
// being discoverable in another one of these iterations.
|
||||||
//
|
//
|
||||||
// Using `instantiate_canonical_with_fresh_inference_vars` on our
|
// Using `instantiate_canonical` on our
|
||||||
// `Canonical<QueryResponse<Ty<'tcx>>>` and then *throwing away* the
|
// `Canonical<QueryResponse<Ty<'tcx>>>` and then *throwing away* the
|
||||||
// `CanonicalVarValues` will exactly give us such a generalization - it
|
// `CanonicalVarValues` will exactly give us such a generalization - it
|
||||||
// will still match the original object type, but it won't pollute our
|
// will still match the original object type, but it won't pollute our
|
||||||
// type variables in any form, so just do that!
|
// type variables in any form, so just do that!
|
||||||
let (QueryResponse { value: generalized_self_ty, .. }, _ignored_var_values) =
|
let (QueryResponse { value: generalized_self_ty, .. }, _ignored_var_values) =
|
||||||
self.fcx.instantiate_canonical_with_fresh_inference_vars(self.span, self_ty);
|
self.fcx.instantiate_canonical(self.span, self_ty);
|
||||||
|
|
||||||
self.assemble_inherent_candidates_from_object(generalized_self_ty);
|
self.assemble_inherent_candidates_from_object(generalized_self_ty);
|
||||||
self.assemble_inherent_impl_candidates_for_type(p.def_id());
|
self.assemble_inherent_impl_candidates_for_type(p.def_id());
|
||||||
|
|
|
@ -38,8 +38,8 @@ mod instantiate;
|
||||||
pub mod query_response;
|
pub mod query_response;
|
||||||
|
|
||||||
impl<'tcx> InferCtxt<'tcx> {
|
impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// Creates an instantiation S for the canonical value with fresh
|
/// Creates an instantiation S for the canonical value with fresh inference
|
||||||
/// inference variables and applies it to the canonical value.
|
/// variables and placeholders then applies it to the canonical value.
|
||||||
/// Returns both the instantiated result *and* the instantiation S.
|
/// Returns both the instantiated result *and* the instantiation S.
|
||||||
///
|
///
|
||||||
/// This can be invoked as part of constructing an
|
/// This can be invoked as part of constructing an
|
||||||
|
@ -50,7 +50,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
/// At the end of processing, the instantiation S (once
|
/// At the end of processing, the instantiation S (once
|
||||||
/// canonicalized) then represents the values that you computed
|
/// canonicalized) then represents the values that you computed
|
||||||
/// for each of the canonical inputs to your query.
|
/// for each of the canonical inputs to your query.
|
||||||
pub fn instantiate_canonical_with_fresh_inference_vars<T>(
|
pub fn instantiate_canonical<T>(
|
||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
canonical: &Canonical<'tcx, T>,
|
canonical: &Canonical<'tcx, T>,
|
||||||
|
|
|
@ -678,7 +678,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
||||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
let infcx = self.build();
|
let infcx = self.build();
|
||||||
let (value, args) = infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical);
|
let (value, args) = infcx.instantiate_canonical(span, canonical);
|
||||||
(infcx, value, args)
|
(infcx, value, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue