Skip to content

Conversation

@ShoyuVanilla
Copy link
Member

Fixes #20975

The issue comes from this assertion:

assert_eq!(coroutine_goals, vec![]);

The deeply normalization goals returns ambiguous errors with type unspecified integer literal because each integer types are all valid candidates.
Normaly, they should be fallbacked into i32 but that's done manually in the type inference, not from the trait solving.

This PR removes deep normalizations on Ty but there are still two places calling it with T: TypeFoldable with non Ty.
I tried to remove the deep normalization entirely from infer, this function.

// FIXME: We should get rid of this method. We cannot deeply normalize during inference, only when finishing.
// Inference should use shallow normalization (`try_structurally_resolve_type()`) only, when needed.
pub(crate) fn normalize_associated_types_in<T>(&mut self, ty: T) -> T
where
T: TypeFoldable<DbInterner<'db>> + Clone,
{
let ty = self.resolve_vars_with_obligations(ty);
self.infer_ctxt
.at(&ObligationCause::new(), self.trait_env.env)
.deeply_normalize(ty.clone())
.unwrap_or(ty)
}

But it caused few regressions especially upon const generic parameters so I left them for now. (Our const evaluation are quite wrong so might need be fixed from there)

I think this is not overlaps with #20974 but this can be waited and rebased upon it if so 😄

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 6, 2025
let ty = self.normalize_associated_types_in(ty);
self.resolve_vars_with_obligations(ty)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ugly function was introduced by me (with some visitors back then) to fix some errors on non-resolved nested opaque types during mir lowering but it isn't needed anymore 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests are seemingly regressed but I believe they are okay because they are errornous types

@ShoyuVanilla
Copy link
Member Author

ShoyuVanilla commented Nov 7, 2025

Well, actually this is mostly done by #20974 😅 I'll just add a test and some minor changes - though this one is minor in overall 😅 - in this PR once it has landed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constant panicking in my project

2 participants