Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/method_resolution/confirm.rs')
-rw-r--r--crates/hir-ty/src/method_resolution/confirm.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/crates/hir-ty/src/method_resolution/confirm.rs b/crates/hir-ty/src/method_resolution/confirm.rs
index 3bdef44dd3..a29e3db18d 100644
--- a/crates/hir-ty/src/method_resolution/confirm.rs
+++ b/crates/hir-ty/src/method_resolution/confirm.rs
@@ -5,6 +5,7 @@ use hir_def::{
FunctionId, GenericDefId, GenericParamId, ItemContainerId, TraitId,
expr_store::path::{GenericArg as HirGenericArg, GenericArgs as HirGenericArgs},
hir::{ExprId, generics::GenericParamDataRef},
+ type_ref::TypeRefId,
};
use rustc_type_ir::{
TypeFoldable,
@@ -15,7 +16,7 @@ use tracing::debug;
use crate::{
Adjust, Adjustment, AutoBorrow, IncorrectGenericsLenKind, InferenceDiagnostic,
- LifetimeElisionKind, PointerCast,
+ LifetimeElisionKind, PointerCast, Span,
db::HirDatabase,
infer::{AllowTwoPhase, AutoBorrowMutability, InferenceContext, TypeMismatch},
lower::{
@@ -190,7 +191,7 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> {
self.ctx.table.register_infer_ok(autoderef.adjust_steps_as_infer_ok());
match pick.autoref_or_ptr_adjustment {
Some(probe::AutorefOrPtrAdjustment::Autoref { mutbl, unsize }) => {
- let region = self.infcx().next_region_var();
+ let region = self.infcx().next_region_var(self.expr.into());
// Type we're wrapping in a reference, used later for unsizing
let base_ty = target;
@@ -254,7 +255,7 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> {
) -> GenericArgs<'db> {
match pick.kind {
probe::InherentImplPick(impl_def_id) => {
- self.infcx().fresh_args_for_item(impl_def_id.into())
+ self.infcx().fresh_args_for_item(self.expr.into(), impl_def_id.into())
}
probe::ObjectPick(trait_def_id) => {
@@ -296,7 +297,7 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> {
// the process we will unify the transformed-self-type
// of the method with the actual type in order to
// unify some of these variables.
- self.infcx().fresh_args_for_item(trait_def_id.into())
+ self.infcx().fresh_args_for_item(self.expr.into(), trait_def_id.into())
}
probe::WhereClausePick(poly_trait_ref) => {
@@ -400,7 +401,7 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> {
let GenericParamId::ConstParamId(const_id) = param_id else {
unreachable!("non-const param ID for const param");
};
- let const_ty = self.ctx.db.const_param_ty_ns(const_id);
+ let const_ty = self.ctx.db.const_param_ty(const_id);
self.ctx.make_body_const(*konst, const_ty).into()
}
_ => unreachable!("unmatching param kinds were passed to `provided_kind()`"),
@@ -409,12 +410,15 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> {
fn provided_type_like_const(
&mut self,
+ type_ref: TypeRefId,
const_ty: Ty<'db>,
arg: TypeLikeConst<'_>,
) -> Const<'db> {
match arg {
- TypeLikeConst::Path(path) => self.ctx.make_path_as_body_const(path, const_ty),
- TypeLikeConst::Infer => self.ctx.table.next_const_var(),
+ TypeLikeConst::Path(path) => {
+ self.ctx.make_path_as_body_const(type_ref, path, const_ty)
+ }
+ TypeLikeConst::Infer => self.ctx.table.next_const_var(Span::Dummy),
}
}
@@ -428,7 +432,7 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> {
) -> GenericArg<'db> {
// Always create an inference var, even when `infer_args == false`. This helps with diagnostics,
// and I think it's also required in the presence of `impl Trait` (that must be inferred).
- self.ctx.table.next_var_for_param(param_id)
+ self.ctx.table.var_for_def(param_id, Span::Dummy)
}
fn parent_arg(&mut self, param_idx: u32, _param_id: GenericParamId) -> GenericArg<'db> {
@@ -609,6 +613,10 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> {
where
T: TypeFoldable<DbInterner<'db>> + Copy,
{
- self.infcx().instantiate_binder_with_fresh_vars(BoundRegionConversionTime::FnCall, value)
+ self.infcx().instantiate_binder_with_fresh_vars(
+ self.expr.into(),
+ BoundRegionConversionTime::FnCall,
+ value,
+ )
}
}