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

Prefer using rustc_middle::ty types over rustc_hir ones #852

Open
Nadrieril opened this issue Aug 14, 2024 · 3 comments
Open

Prefer using rustc_middle::ty types over rustc_hir ones #852

Nadrieril opened this issue Aug 14, 2024 · 3 comments

Comments

@Nadrieril
Copy link
Collaborator

A number of rustc types have two versions: one in the HIR, the other in rustc_middle::ty. For example GenericParam vs GenericParamDef or WherePredicate vs Predicate. The HIR version is more syntactic, the ty version is more semantic.

We often copy both versions in the frontend, because they happen to show up in other types we need. I propose that when possible we substitute the ty version for the HIR one, as I suspect the ty ones are more convenient to use for our purposes.

Copy link

This issue has been marked as stale due to a lack of activity for 60 days. If you believe this issue is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days.

@github-actions github-actions bot added the stale label Oct 14, 2024
@W95Psp W95Psp removed the stale label Oct 14, 2024
@W95Psp
Copy link
Collaborator

W95Psp commented Oct 14, 2024

Still relevant

@Nadrieril
Copy link
Collaborator Author

Nadrieril commented Oct 16, 2024

List of types we can migrate this way:

  • hir::GenericParam -> ty::GenericParam
  • hir::Generics -> ty::GenericArg
  • hir::Ty -> we should never interact with this, only ty::Ty
  • hir::FieldDef -> ty::FieldDef
  • hir::FnSig -> ty::PolyFnSig

After that, the most powerful change we could do would be to migrate from hir::Item to hax::FullDef. This would transitively allow removing ~30 hir::* types without needing to add any new ones.

List of `hir::*` types that are only used transitively by one of the above types:
  • hir::AnonConst
  • hir::AssocItemKind
  • hir::ConstArg
  • hir::ConstArgKind
  • hir::Constness
  • hir::EnumDef
  • hir::FnDecl
  • hir::FnHeader
  • hir::FnRetTy
  • hir::ForeignItem
  • hir::ForeignItemKind
  • hir::ForeignItemRef
  • hir::GenericBounds
  • hir::GenericParamKind
  • hir::Impl
  • hir::ImplItem
  • hir::ImplItemKind
  • hir::ImplItemRef
  • hir::ImplPolarity
  • hir::IsAsync
  • hir::IsAuto
  • hir::ItemId
  • hir::ItemKind
  • hir::LifetimeParamKind
  • hir::Mod
  • hir::OpaqueTy
  • hir::OpaqueTyOrigin
  • hir::ParamName
  • hir::PathSegment
  • hir::PrimTy
  • hir::TraitItem
  • hir::TraitItemKind
  • hir::TraitItemRef
  • hir::UseKind
  • hir::UsePath
  • hir::Variant
  • hir::VariantData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

No branches or pull requests

2 participants