Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate definitions and HIR owners in the type system #83158

Closed
cjgillot opened this issue Mar 15, 2021 · 6 comments · Fixed by #102040
Closed

Separate definitions and HIR owners in the type system #83158

cjgillot opened this issue Mar 15, 2021 · 6 comments · Fixed by #102040
Assignees
Labels
A-HIR Area: The high-level intermediate representation (HIR) E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cjgillot
Copy link
Contributor

cjgillot commented Mar 15, 2021

Both definitions and HIR owners are represented by a LocalDefId,
but they don't have the same semantics.

HIR owners are the owner field of a HirId,
and the argument passed to the hir_owner* queries.
HIR owners contain the following HIR nodes: Item, TraitItem, ImplItem, ForeignItem, MacroDef,
and GenericParams which come from impl Trait desugaring.

LocalDefId enumerate definitions in the local crate.
Definitions are a broader concept than HIR owners.
For instance, closures are definitions but not HIR owners.

On the other hand, all HIR owners are definitions.

We need to introduce a new type HirOwner type (name to bikeshed),
whose usage will be the following:

  • HirOwner is defined as struct HirOwner { def_id: LocalDefId };
  • HirId becomes { owner: HirOwner, local_id: ItemLocalId };
  • Item, TraitItem, ImplItem, ForeignItem, MacroDef have a HirOwner as their def_id field;
  • hir_owner* queries take a HirOwner as argument;
  • the passage between HirOwner and LocalDefId happens through
    the local_def_id_to_hir_id: LocalDefId -> HirId
    and local_def_id: HirId -> LocalDefId methods.

I am available on Zulip for further information.

@cjgillot cjgillot added E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. A-HIR Area: The high-level intermediate representation (HIR) E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. labels Mar 15, 2021
@jyn514 jyn514 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 15, 2021
@osa1
Copy link
Contributor

osa1 commented Mar 16, 2021

@rustbot claim

I'd like to do this. @cjgillot I'll ping you on Zulip with questions.

@osa1
Copy link
Contributor

osa1 commented Mar 27, 2021

I don't understand HIR ownership and I'm working on other issues currently. I'm hoping to come back to this but if anyone wants to do it in the meantime please feel free to pick this up.

@osa1 osa1 removed their assignment Mar 27, 2021
@Rustin170506
Copy link
Member

@rustbot claim

@Rustin170506 Rustin170506 removed their assignment May 3, 2021
@ABouttefeux
Copy link
Contributor

@rustbot claim

@kckeiks
Copy link
Contributor

kckeiks commented Apr 12, 2022

@ABouttefeux Are you still working on this? I would like to pick this up.

@ABouttefeux
Copy link
Contributor

@kckeiks I am not working on that please go ahead. Sorry for not responding sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-HIR Area: The high-level intermediate representation (HIR) E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
7 participants