Skip to content

Fix ICE while computing type layout #14837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented May 18, 2025

If a type is incomplete, for example if generic parameters are not available yet, although they are not escaping, its layout may not be computable. Calling TyCtxt::layout_of() would create a delayed bug in the compiler.

changelog: [zero_sized_map_values]: fix ICE

Fixes #14822

r? @Jarcho

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 18, 2025
@Jarcho Jarcho added the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 19, 2025
@Jarcho
Copy link
Contributor

Jarcho commented May 19, 2025

Looks like the delay_bug had just been moved around a bit, not actually removed.

The test case can be simplified to:

trait Trait { type T; }
struct S<T: Trait>(T::T);
type Map<T> = HashMap<u32, *const S<T>>;

The delay_bug happens when evaluating the pointer metadata of S<T> which depends on whether T::T is Sized. Since the type alias doesn't have a trait bound of T: Trait evaluating T::T: Sized ultimately fails with NoSolution.

Can you add a comment roughly explaining what actually causes the delay_bug?

If a type is incomplete, for example if generic parameters are not
available yet, although they are not escaping, its layout may not
be computable. Calling `TyCtxt::layout_of()` would create a delayed bug
in the compiler.
@samueltardieu
Copy link
Contributor Author

Can you add a comment roughly explaining what actually causes the delay_bug?

I have reused your explanation as-is, and the simplified test case.

Copy link
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

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

Thank you.

@Jarcho Jarcho added this pull request to the merge queue May 19, 2025
Merged via the queue into rust-lang:master with commit 6753e16 May 19, 2025
11 checks passed
@samueltardieu samueltardieu deleted the issue-14822 branch May 20, 2025 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-nominated Nominated for backporting to the compiler in the beta channel. 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.

ICE unexpected ambiguity: CanonicalQueryInput
3 participants