fix: Fix method resolution snapshotting receiver_ty too early

This commit is contained in:
Lukas Wirth 2024-03-11 15:35:06 +01:00
parent 8f8bcfc131
commit fdc527f096
3 changed files with 48 additions and 42 deletions

View file

@ -438,7 +438,6 @@ impl<'a> InferenceTable<'a> {
where
T: HasInterner<Interner = Interner> + TypeFoldable<Interner>,
{
// TODO check this vec here
self.resolve_with_fallback_inner(&mut Vec::new(), t, &fallback)
}

View file

@ -1060,27 +1060,26 @@ fn iterate_method_candidates_by_receiver(
name: Option<&Name>,
mut callback: &mut dyn FnMut(ReceiverAdjustments, AssocItemId, bool) -> ControlFlow<()>,
) -> ControlFlow<()> {
let receiver_ty = table.instantiate_canonical(receiver_ty.clone());
// We're looking for methods with *receiver* type receiver_ty. These could
// be found in any of the derefs of receiver_ty, so we have to go through
// that, including raw derefs.
table.run_in_snapshot(|table| {
let mut autoderef = autoderef::Autoderef::new(table, receiver_ty.clone(), true);
while let Some((self_ty, _)) = autoderef.next() {
iterate_inherent_methods(
&self_ty,
autoderef.table,
name,
Some(&receiver_ty),
Some(receiver_adjustments.clone()),
visible_from_module,
&mut callback,
)?
}
ControlFlow::Continue(())
})?;
table.run_in_snapshot(|table| {
let receiver_ty = table.instantiate_canonical(receiver_ty.clone());
// We're looking for methods with *receiver* type receiver_ty. These could
// be found in any of the derefs of receiver_ty, so we have to go through
// that, including raw derefs.
table.run_in_snapshot(|table| {
let mut autoderef = autoderef::Autoderef::new(table, receiver_ty.clone(), true);
while let Some((self_ty, _)) = autoderef.next() {
iterate_inherent_methods(
&self_ty,
autoderef.table,
name,
Some(&receiver_ty),
Some(receiver_adjustments.clone()),
visible_from_module,
&mut callback,
)?
}
ControlFlow::Continue(())
})?;
let mut autoderef = autoderef::Autoderef::new(table, receiver_ty.clone(), true);
while let Some((self_ty, _)) = autoderef.next() {
iterate_trait_method_candidates(