Skip to content

Commit 4f84b7a

Browse files
committed
fix: propagate owner_fn_id of type parameters
1 parent 97ac7b1 commit 4f84b7a

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ impl<'tcx> Analyzer<'tcx> {
435435
owner_fn_id,
436436
)
437437
.with_generic_args(generic_args)
438-
.with_def_id_cache(self.def_ids());
438+
.with_def_id_cache(self.def_ids(), owner_fn_id);
439439
let formula_fn = translator.to_formula_fn();
440440
deferred_formula_fn_cache
441441
.borrow_mut()

src/analyze/annot_fn.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ impl<'tcx> AnnotFnTranslator<'tcx> {
191191
self
192192
}
193193

194-
pub fn with_def_id_cache(mut self, def_ids: DefIdCache<'tcx>) -> Self {
194+
pub fn with_def_id_cache(mut self, def_ids: DefIdCache<'tcx>, owner_fn_id: DefId) -> Self {
195195
self.def_ids = def_ids;
196196
self.type_builder = TypeBuilder::new(
197197
self.tcx,
198198
self.def_ids.clone(),
199-
self.local_def_id.to_def_id(),
199+
owner_fn_id,
200200
self.type_params.clone(),
201201
self.system.clone(),
202202
);
@@ -253,7 +253,9 @@ impl<'tcx> AnnotFnTranslator<'tcx> {
253253
.instantiate_generics(ty, self.generic_args)
254254
.unwrap_or(ty);
255255
let typing_env = mir_ty::TypingEnv::fully_monomorphized();
256-
self.tcx.normalize_erasing_regions(typing_env, instantiated)
256+
self.tcx
257+
.try_normalize_erasing_regions(typing_env, instantiated)
258+
.unwrap_or(instantiated)
257259
}
258260

259261
fn pat_ty(&self, pat: &'tcx rustc_hir::Pat<'tcx>) -> mir_ty::Ty<'tcx> {
@@ -572,6 +574,11 @@ impl<'tcx> AnnotFnTranslator<'tcx> {
572574
self.type_builder.build(ty).to_sort()
573575
})
574576
.collect();
577+
tracing::debug!(
578+
"register ForallPred {:?} with signature {:?}",
579+
pred,
580+
sig
581+
);
575582
self.system
576583
.borrow_mut()
577584
.register_forall_pred(pred.clone(), sig);

src/refine/template.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,10 @@ impl<'tcx> TypeBuilder<'tcx> {
146146
.entry(TypeParam::AssocType(ty.def_id))
147147
.or_insert_with(|| {
148148
let idx = self.system.borrow_mut().new_forall_sort();
149-
tracing::debug!(
150-
"issue the new ForallSortIdx {} for AliasTy {:?}.",
151-
idx,
152-
ty,
153-
);
149+
tracing::debug!("issue the new ForallSortIdx {} for AliasTy {:?}.", idx, ty,);
154150
idx
155151
});
156-
152+
157153
rty::AliasType::new(*index).into()
158154
}
159155

0 commit comments

Comments
 (0)