Skip to content

fix: Crash on lowering consts with associated types#22646

Open
Wilfred wants to merge 1 commit into
rust-lang:masterfrom
Wilfred:another_interesting_crash
Open

fix: Crash on lowering consts with associated types#22646
Wilfred wants to merge 1 commit into
rust-lang:masterfrom
Wilfred:another_interesting_crash

Conversation

@Wilfred

@Wilfred Wilfred commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Previously we'd modify TyLoweringContext::store without modifying TyLoweringContext::def. This causes a crash later when we try to look up the expression in the wrong store:

thread 'main' panicked at crates/hir-ty/src/infer/expr.rs:326:
should have `ExpressionStore::expr_only`

Instead, ensure we update both consistently so we can find the expression.

Add a regression test (based on code originally seen in the bitmaps crate version 3.2.1).

AI disclosure: Bisected and coded with help from Codex and GPT-5.5.

Previously we'd modify TyLoweringContext::store without modifying
TyLoweringContext::def. This causes a crash later when we try to look
up the expresison in the wrong store:

    thread 'main' panicked at crates/hir-ty/src/infer/expr.rs:326:
    should have `ExpressionStore::expr_only`

Instead, ensure we update both consistently so we can find the
expression.

Add a regression test (based on code originally seen in the bitmaps
crate version 3.2.1).

AI disclosure: Bisected and coded with help from Codex and GPT-5.5.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 26, 2026
@Wilfred

Wilfred commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Issues that look related: #22175, #22341.

This was found with me bisecting another SCIP issue on some large codebases, it keeps finding cursed interesting patterns :)

The code looks sensible, I think the invariant it's preserving is the right thing to do, but let me know if there's a better way.

@ChayimFriedman2 ChayimFriedman2 left a comment

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.

Maybe have a TyLoweringContext::set_owner(owner: &SingleGenerics)?

View changes since this review

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.

3 participants