Rollup merge of #123016 - compiler-errors:no-type-var-origin, r=lcnr
Remove `TypeVariableOriginKind` and `ConstVariableOriginKind` It's annoying to have to import `TypeVariableOriginKind` just to fill it with `MiscVariable` for almost every use. Every other usage other than `TypeParameterDefinition` wasn't even used -- I can see how it may have been useful once for debugging, but I do quite a lot of typeck debugging and I've never really needed it. So let's just remove it, and keep around the only useful thing which is the `DefId` of the param for `var_for_def`. This is based on #123006, which removed the special use of `TypeVariableOriginKind::OpaqueInference`, which I'm pretty sure I was the one that added. r? lcnr or re-roll to types
This commit is contained in:
commit
9cc26b598a
43 changed files with 208 additions and 409 deletions
|
@ -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,
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ use rustc_infer::traits::query::NoSolution;
|
|||
use rustc_infer::traits::solve::{MaybeCause, NestedNormalizationGoals};
|
||||
use rustc_infer::traits::ObligationCause;
|
||||
use rustc_middle::infer::canonical::CanonicalVarInfos;
|
||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||
use rustc_middle::infer::unify_key::ConstVariableOrigin;
|
||||
use rustc_middle::traits::solve::inspect;
|
||||
use rustc_middle::traits::solve::{
|
||||
CanonicalInput, CanonicalResponse, Certainty, PredefinedOpaques, PredefinedOpaquesData,
|
||||
|
@ -587,17 +587,11 @@ 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> {
|
||||
self.infcx.next_const_var(
|
||||
ty,
|
||||
ConstVariableOrigin { kind: ConstVariableOriginKind::MiscVariable, span: DUMMY_SP },
|
||||
)
|
||||
self.infcx.next_const_var(ty, ConstVariableOrigin { param_def_id: None, span: DUMMY_SP })
|
||||
}
|
||||
|
||||
/// Returns a ty infer or a const infer depending on whether `kind` is a `Ty` or `Const`.
|
||||
|
|
|
@ -3,11 +3,11 @@ 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};
|
||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||
use rustc_middle::infer::unify_key::ConstVariableOrigin;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::ty::{self, AliasTy, Ty, TyCtxt, UniverseIndex};
|
||||
use rustc_middle::ty::{FallibleTypeFolder, TypeFolder, TypeSuperFoldable};
|
||||
|
@ -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(),
|
||||
|
@ -124,10 +122,7 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
|
|||
|
||||
let new_infer_ct = infcx.next_const_var(
|
||||
ty,
|
||||
ConstVariableOrigin {
|
||||
kind: ConstVariableOriginKind::MiscVariable,
|
||||
span: self.at.cause.span,
|
||||
},
|
||||
ConstVariableOrigin { param_def_id: None, span: self.at.cause.span },
|
||||
);
|
||||
let obligation = Obligation::new(
|
||||
tcx,
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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] }
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue