Skip to content

Use special DefIds for aliases#155025

Closed
ChayimFriedman2 wants to merge 1 commit intorust-lang:mainfrom
ChayimFriedman2:alias-def-id
Closed

Use special DefIds for aliases#155025
ChayimFriedman2 wants to merge 1 commit intorust-lang:mainfrom
ChayimFriedman2:alias-def-id

Conversation

@ChayimFriedman2
Copy link
Copy Markdown
Contributor

Like we do for other things for better experience in rust-analyzer.

It's possible now that the AliasTyKind contains the DefId. It does require a few unwraps since AliasTermKind still does not contain the DefId and some things only include a DefId with no kind, but IMO it's still better.

r? types

Like we do for other things for better experience in rust-analyzer.

It's possible now that the `AliasTyKind` contains the DefId. It does require a few unwraps since `AliasTermKind` still does not contain the DefId and some things only include a DefId with no kind, but IMO it's still better.
@jieyouxu jieyouxu added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-types Relevant to the types team, which will review and decide on the PR/issue. labels Apr 9, 2026
@jackh726
Copy link
Copy Markdown
Member

jackh726 commented Apr 13, 2026

LGTM but I want to r? lcnr

@rustbot rustbot assigned lcnr and unassigned jackh726 Apr 13, 2026
Comment on lines +43 to +47
type ProjectionTyId = DefId;
type ProjectionId = DefId;
type OpaqueId = DefId;
type FreeAliasId = DefId;
type ImplTyAliasId = DefId;
Copy link
Copy Markdown
Contributor

@lcnr lcnr Apr 13, 2026

Choose a reason for hiding this comment

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

View changes since the review

Suggested change
type ProjectionTyId = DefId;
type ProjectionId = DefId;
type OpaqueId = DefId;
type FreeAliasId = DefId;
type ImplTyAliasId = DefId;
type DefinitionAssocTyId = DefId;
type DefinitionAssocTermId = DefId;
type OpaqueTyId = DefId;
type FreeAliasId = DefId;
type ImplAssocTyId = DefId;

maybe?

generally r=me, I did consider the fact that we can do this with our AliasTy changes

Copy link
Copy Markdown
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

maybe it's better to wait until we also do this for AliasTermKind as then we don't need map back and forth between DefId and the more specific ones as much?

View changes since this review

Comment on lines +628 to +637
AliasTermKind::ProjectionTy => {
AliasTyKind::Projection { def_id: self.def_id.try_into().unwrap() }
}
AliasTermKind::InherentTy => {
AliasTyKind::Inherent { def_id: self.def_id.try_into().unwrap() }
}
AliasTermKind::OpaqueTy => {
AliasTyKind::Opaque { def_id: self.def_id.try_into().unwrap() }
}
AliasTermKind::FreeTy => AliasTyKind::Free { def_id: self.def_id.try_into().unwrap() },
Copy link
Copy Markdown
Contributor

@lcnr lcnr Apr 13, 2026

Choose a reason for hiding this comment

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

View changes since the review

e.g. this is kind of a mess and will be unnecessary once AliasTermKind also contains the specific defIds

@ChayimFriedman2
Copy link
Copy Markdown
Contributor Author

Whatever you prefer. I wasn't sure if it is planned for AliasTermKind to carry a DefId as well.

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Apr 13, 2026

ye, should happen soon, cc @WaffleLapkin :3

@WaffleLapkin
Copy link
Copy Markdown
Member

I'm indeed working on refactoring AliasTermKind as well, but it's taking a bit longer because... life ^^'

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 19, 2026

☔ The latest upstream changes (presumably #155223) made this pull request unmergeable. Please resolve the merge conflicts.

@ChayimFriedman2
Copy link
Copy Markdown
Contributor Author

I'm closing this for now then.

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 20, 2026
@ChayimFriedman2 ChayimFriedman2 deleted the alias-def-id branch April 30, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants