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

Generate structural type invariants #801

Merged
merged 12 commits into from
Jun 14, 2023
Merged

Generate structural type invariants #801

merged 12 commits into from
Jun 14, 2023

Conversation

voidc
Copy link
Collaborator

@voidc voidc commented Jun 6, 2023

This includes all the code for generating structural invariants but does not yet actually generate them when adding type invariants. This will be in a follow-up PR.

@voidc voidc force-pushed the tyinv-gen branch 10 times, most recently from 19d419a to 5825771 Compare June 13, 2023 06:47
@voidc voidc force-pushed the tyinv-gen branch 2 times, most recently from e768e46 to 4e64e32 Compare June 14, 2023 13:02
@voidc voidc marked this pull request as ready for review June 14, 2023 13:03
let generics = ty_param_names(ctx.tcx, def_id).collect();
(generics, subst)
} else if let DepNode::TyInv(ty) = dep {
let generics = TyInvKind::from_ty(ty).generics(ctx.tcx);
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

#[inline]
pub(crate) fn erase_regions(mut self, tcx: TyCtxt<'tcx>) -> Self {
match &mut self {
Dependency::Item(_, s) => *s = tcx.erase_regions(*s),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if you couldn't derive TypeFoldable for Dependency and get this for free?

@xldenis
Copy link
Collaborator

xldenis commented Jun 14, 2023

A few nits about the code, and we've already talked about the remaining larger issues in mattermost. I think this is pretty much ready to merge as a first step though!

@@ -38,7 +38,7 @@ impl TyInvKind {
}
}

pub(crate) fn to_ty<'tcx>(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
pub(crate) fn to_skeleton_ty<'tcx>(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove pub(crate)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, the function is used to build the self node in the clone map.

@voidc voidc enabled auto-merge June 14, 2023 17:16
@voidc voidc merged commit ee50ea2 into master Jun 14, 2023
@voidc voidc deleted the tyinv-gen branch June 14, 2023 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants