8000 fix: Remove `SolverDefId::ForeignId` by ChayimFriedman2 · Pull Request #20545 · rust-lang/rust-analyzer · GitHub
[go: up one dir, main page]

Skip to content

Conversation

ChayimFriedman2
Copy link
Contributor
@ChayimFriedman2 ChayimFriedman2 commented Aug 26, 2025

Replace it with normal SolverDefId::TypeAliasId.

The split caused a very funny bug where code was getting TypeAliasId where it expected ForeignId, because TypeAliasId had a From impl from hir_def::TypeAliasId and ForeignId had not, plus a careless into().

I could've fixed this specific bug but opted to remove the split instead; currently, it just provides more room for bugs, as we don't have typed IDs for the solver anyway, and even when we'll have (hopefully), that doesn't seem like a very useful distinction, for example in hir-def foreign types are just TypeAliasId with some flags.

Constructing a test for this isn't trivial; the trivial test (creating a foreign type, even proving a trait bound for it) fails to fail before the change, probably because we don't use the new solver everywhere yet so we don't trigger this specific code path.

Fixes #20544.

Replace it with normal `SolverDefId::TypeAliasId`.

The split caused a very funny bug where code was getting `TypeAliasId` where it expected `ForeignId`, because `TypeAliasId` had a `From` impl from `hir_def::TypeAliasId` and `ForeignId` had not, plus a careless `into()`.

I could've fixed this specific bug but opted to remove the split instead; currently, it just provides more room for bugs, as we don't have typed IDs for the solver anyway, and even when we'll have (hopefully), that doesn't seem like a very useful distinction, for example in hir-def foreign types are just `TypeAliasId` with some flags.

Constructing a test for this isn't trivial; the trivial test (creating a foreign type, even proving a trait bound for it) fails to fail before the change, probably because we don't use the new solver everywhere yet so we don't trigger this specific code path.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 26, 2025
@lnicola lnicola added this pull request to the merge queue Aug 26, 2025
@lnicola
Copy link
Member
lnicola commented Aug 26, 2025

changelog fixup #20329

Merged via the queue into rust-lang:master with commit 1f4e5e8 Aug 26, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 26, 2025
@ChayimFriedman2 ChayimFriedman2 deleted the ns-foreign branch August 26, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

crates/hir-ty/src/next_solver/mapping.rs:1256:22: internal error: entered unreachable code
3 participants
0