Skip to content

fix: Refactor handling of generic params in hir::Type#22252

Open
ChayimFriedman2 wants to merge 2 commits intorust-lang:masterfrom
ChayimFriedman2:hir-types
Open

fix: Refactor handling of generic params in hir::Type#22252
ChayimFriedman2 wants to merge 2 commits intorust-lang:masterfrom
ChayimFriedman2:hir-types

Conversation

@ChayimFriedman2
Copy link
Copy Markdown
Contributor

The essence of the new handling is that hir::Type now remembers its owner (and not ParamEnv; we could remember both but that is unnecessary) and refuse (panics) to work with types not from the same owner. It would be best if we could enforce this statically, but unfortunately we can't.

Fixes #21220
Fixes #21849 (probably, haven't checked).

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 3, 2026
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

…reOwnedId`

A `ParamEnv` is fundamentally associated with generic arguments and not with a body. It feels wrong to attach it to `ExpressionStoreOwnedId`.

There is one exception: a defaulted trait method with RPITIT has a different ParamEnv inside its body than for its callers, since inside the body the RPITIT is interpreted as an RPIT equating the internal assoc type. We don't yet handle RPITIT, but even when we'll do I don't feel it's justifies treating *any* body as different.
The essence of the new handling is that `hir::Type` now remembers its owner (and not `ParamEnv`; we could remember both but that is unnecessary) and refuse (panics) to work with types not from the same owner. It would be best if we could enforce this statically, but unfortunately we can't.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

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 textDocument/completion failed Auto completion failed with nalgebra

2 participants