-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
removing new_from_def_id and alias_ty_kind_from_def_id methods, small refactor to TypeRelativePath::AssocItem
#155323
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -298,7 +298,7 @@ pub enum PermitVariants { | |
|
|
||
| #[derive(Debug, Clone, Copy)] | ||
| enum TypeRelativePath<'tcx> { | ||
| AssocItem(DefId, GenericArgsRef<'tcx>), | ||
| AssocItem(ty::AliasTyKind<'tcx>, GenericArgsRef<'tcx>), | ||
| Variant { adt: Ty<'tcx>, variant_did: DefId }, | ||
| Ctor { ctor_def_id: DefId, args: GenericArgsRef<'tcx> }, | ||
| } | ||
|
|
@@ -1400,12 +1400,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | |
| span, | ||
| LowerTypeRelativePathMode::Type(permit_variants), | ||
| )? { | ||
| TypeRelativePath::AssocItem(def_id, args) => { | ||
| let alias_ty = ty::AliasTy::new_from_args( | ||
| tcx, | ||
| ty::AliasTyKind::new_from_def_id(tcx, def_id), | ||
| args, | ||
| ); | ||
| TypeRelativePath::AssocItem(alias_kind, args) => { | ||
| let def_id = alias_kind.def_id(); | ||
| let alias_ty = ty::AliasTy::new_from_args(tcx, alias_kind, args); | ||
| let ty = Ty::new_alias(tcx, alias_ty); | ||
| let ty = self.check_param_uses_if_mcg(ty, span, false); | ||
| Ok((ty, tcx.def_kind(def_id), def_id)) | ||
|
|
@@ -1440,7 +1437,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | |
| span, | ||
| LowerTypeRelativePathMode::Const, | ||
| )? { | ||
| TypeRelativePath::AssocItem(def_id, args) => { | ||
| TypeRelativePath::AssocItem(alias_kind, args) => { | ||
| let def_id = alias_kind.def_id(); | ||
| self.require_type_const_attribute(def_id, span)?; | ||
| let ct = Const::new_unevaluated(tcx, ty::UnevaluatedConst::new(def_id, args)); | ||
| let ct = self.check_param_uses_if_mcg(ct, span, false); | ||
|
|
@@ -1572,15 +1570,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | |
| } | ||
|
|
||
| // FIXME(inherent_associated_types, #106719): Support self types other than ADTs. | ||
| if let Some((did, args)) = self.probe_inherent_assoc_item( | ||
| if let Some((def_id, args)) = self.probe_inherent_assoc_item( | ||
| segment, | ||
| adt_def.did(), | ||
| self_ty, | ||
| qpath_hir_id, | ||
| span, | ||
| mode.assoc_tag(), | ||
| )? { | ||
| return Ok(TypeRelativePath::AssocItem(did, args)); | ||
| return Ok(TypeRelativePath::AssocItem(ty::Inherent { def_id }, args)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -1614,7 +1612,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | |
| ); | ||
| } | ||
|
|
||
| Ok(TypeRelativePath::AssocItem(item_def_id, args)) | ||
| Ok(TypeRelativePath::AssocItem(ty::Projection { def_id: item_def_id }, args)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, |
||
| } | ||
|
|
||
| /// Resolve a [type-relative](hir::QPath::TypeRelative) (and type-level) path. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is misleading,
AssocItemcan represent associated constants under mGCA.You can see yourself how in
lower_type_relative_const_pathyou merely extract theDefIdand ignore the actual kind.Conceptually this
(DefId, GenericArgRef)is anAliasTerm.If anything, the entire payload should either be changed to
AliasTermor to(AliasTermKind, GenericArgsRef)if we don't want to intern it too early or it should just remain as is if the other options end up disimproving the lowering code.View changes since the review
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think the
AliasTermchange makes sense.this may be a dumb question but when you mention the other option:
(AliasTermKind, GenericArgsRef). I looked at it here and it doesn't seem to have aDefIdthough it appears to be the long term goal based on the last task in the linked issue:did you mean
(AliasTermKind, DefId, GenericArgsRef)?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, not a dumb question at all! I'm only loosely following #154941, so I didn't realize that
AliasTermKindwasn't updated yet and just assumed it was.Right,
(AliasTermKind, DefId, GenericArgsRef)would be an option or we wait untilAliasTermKindhas aDefId. I don't want to call the shots here though since WaffleLapkin guides this initiative.I'm just the self-proclaimed janitor of HIR ty lowering :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to
AliasTermhere: dc59a2athough now that I'm looking at it, it's still using the methods
new_from_def_idandalias_ty_kind_from_def_idUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i raised #155371 as an alternative for the
option. lmk what you think(AliasTermKind, DefId, GenericArgsRef)edit: now
(AliasTermKind, GenericArgsRef)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmease I think this PR is outdated as #155392 added a
DefIdforAliasTermKindnow so the option,(AliasTermKind, GenericArgsRef), should be viable nowmeaning i'm closing this one but want to let you know