Skip to content

fix: Fix typed_hole panic - #22858

Open
Veykril wants to merge 1 commit into
rust-lang:masterfrom
Veykril:lukaswirth/push-lvrknnmvnwtq
Open

fix: Fix typed_hole panic#22858
Veykril wants to merge 1 commit into
rust-lang:masterfrom
Veykril:lukaswirth/push-lvrknnmvnwtq

Conversation

@Veykril

@Veykril Veykril commented Jul 19, 2026

Copy link
Copy Markdown
Member

Fixes #22659

Also makes the hir type unification API more resilient to mistakes in release builds

@Veykril
Veykril force-pushed the lukaswirth/push-lvrknnmvnwtq branch from d8419aa to dd6ecda Compare July 19, 2026 11:14
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 19, 2026
@ChayimFriedman2

Copy link
Copy Markdown
Contributor

How does this relate to #22662?

Comment thread crates/hir/src/lib.rs
Comment on lines +5480 to +5483
self.try_rebase_into(db, rebase_into).unwrap_or_else(|| Type {
owner: rebase_into.owner,
ty: self.instantiate_with_errors().ty,
})

@ChayimFriedman2 ChayimFriedman2 Jul 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change makes it less flexible (although it doesn't really matter): instantiate_with_errors() returns a NoParams owner, which unifies (not just rebases) with any owner.

View changes since the review

Comment thread crates/hir/src/lib.rs
self.owner.must_unify(other.owner);
let env = self.param_env(db);
let Some(owner) = self.owner.unify(other.owner) else {
never!("callers should not mix owners");

@ChayimFriedman2 ChayimFriedman2 Jul 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably a good idea to still have must_unify() just for this never!()?

We can also have a macro for the return false but that's probably not a good idea.

View changes since the review

Comment thread crates/hir/src/lib.rs
never!("callers should not mix owners");
return false;
};
let env = Type { owner, ty: self.ty }.param_env(db);

@ChayimFriedman2 ChayimFriedman2 Jul 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this change? Given that we return on unification failure (and we must, otherwise we can panic) we can leave this as self.param_env(db).

View changes since the review

@Veykril

Veykril commented Jul 19, 2026

Copy link
Copy Markdown
Member Author

Ah I missed your PR

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.

request handler panicked: failed to unify type owners

3 participants