1
Fork 0

Remove TypeVariableOriginKind

This commit is contained in:
Michael Goulet 2024-03-24 12:47:01 -04:00
parent 99d0186b1d
commit 34bce07e8e
39 changed files with 154 additions and 307 deletions

View file

@ -2,7 +2,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir::def_id::DefId;
use rustc_infer::infer::at::ToTrace;
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::{
BoundRegionConversionTime, DefineOpaqueTypes, InferCtxt, InferOk, TyCtxtInferExt,
};
@ -587,10 +587,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}
pub(super) fn next_ty_infer(&self) -> Ty<'tcx> {
self.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP,
})
self.infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: DUMMY_SP })
}
pub(super) fn next_const_infer(&self, ty: Ty<'tcx>) -> ty::Const<'tcx> {

View file

@ -3,7 +3,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt;
use crate::traits::{BoundVarReplacer, PlaceholderReplacer};
use rustc_data_structures::stack::ensure_sufficient_stack;
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::traits::TraitEngineExt;
use rustc_infer::traits::{FulfillmentError, Obligation, TraitEngine};
@ -74,10 +74,8 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
self.depth += 1;
let new_infer_ty = infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::NormalizeProjectionType,
span: self.at.cause.span,
});
let new_infer_ty =
infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.at.cause.span });
let obligation = Obligation::new(
tcx,
self.at.cause.clone(),

View file

@ -1,4 +1,4 @@
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::type_variable::TypeVariableOrigin;
use crate::infer::InferCtxt;
use crate::traits::{Obligation, ObligationCause, ObligationCtxt};
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 };
// Make a fresh inference variable so we can determine what the generic parameters
// of the trait are.
let var = self.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
});
let var =
self.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None });
// FIXME(effects)
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, [ty.skip_binder(), var]);
let obligation = Obligation::new(

View file

@ -24,7 +24,7 @@ use rustc_hir::is_range_literal;
use rustc_hir::lang_items::LangItem;
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node};
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_middle::hir::map;
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()) => {
infcx.tcx.mk_fn_sig(
*inputs,
infcx.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
}),
infcx
.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
false,
hir::Unsafety::Normal,
abi::Abi::Rust,
@ -1905,10 +1903,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
_ => infcx.tcx.mk_fn_sig(
[inputs],
infcx.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
}),
infcx.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
false,
hir::Unsafety::Normal,
abi::Abi::Rust,
@ -4269,7 +4264,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
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
// expression we're looking at now, so that we can tell what
// for example `Iterator::Item` is at this point in the chain.

View file

@ -6,7 +6,7 @@ use crate::errors::{
AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch,
};
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::{self, InferCtxt};
use crate::traits::error_reporting::infer_ctxt_ext::InferCtxtExt;
@ -2820,10 +2820,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
if let ty::Param(_) = *ty.kind() {
let infcx = self.infcx;
*self.var_map.entry(ty).or_insert_with(|| {
infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP,
})
infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: DUMMY_SP })
})
} else {
ty.super_fold_with(self)

View file

@ -18,7 +18,7 @@ use rustc_middle::traits::ImplSource;
use rustc_middle::traits::ImplSourceUserDefinedData;
use crate::errors::InherentProjectionNormalizationOverflow;
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::type_variable::TypeVariableOrigin;
use crate::infer::{BoundRegionConversionTime, InferOk};
use crate::traits::normalize::normalize_with_depth;
use crate::traits::normalize::normalize_with_depth_to;
@ -522,7 +522,7 @@ fn normalize_to_error<'a, 'tcx>(
};
let tcx = selcx.infcx.tcx;
let new_value = selcx.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::NormalizeProjectionType,
param_def_id: None,
span: tcx.def_span(projection_ty.def_id),
});
Normalized { value: new_value, obligations: vec![trait_obligation] }

View file

@ -1,5 +1,5 @@
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_middle::ty::{self, Ty};
@ -19,10 +19,9 @@ impl<'tcx> At<'_, 'tcx> {
return Ok(ty);
};
let new_infer_ty = self.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::NormalizeProjectionType,
span: self.cause.span,
});
let new_infer_ty = self
.infcx
.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
// normalizing the LHS of the projection until it is a rigid projection