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

Hide associated types equality constraints #127

Closed
Nadrieril opened this issue Apr 16, 2024 · 2 comments · Fixed by #532
Closed

Hide associated types equality constraints #127

Nadrieril opened this issue Apr 16, 2024 · 2 comments · Fixed by #532
Assignees
Labels
C-simplification-pass Request for charon to process the output llbc

Comments

@Nadrieril
Copy link
Member

Nadrieril commented Apr 16, 2024

The following is unsupported because we don't handle the equality constraint:

trait Iterator {
    type Item;
}

fn f<I, J>(x: I::Item) -> J::Item
where
    I: Iterator,
    J: Iterator<Item=I::Item>,
{ x }

The solution proposed by @sonmarcho would be to transform associated types into type parameters. Type equalities would then only apply to free type variables, which we can handle by merging any two variables that are equated. We would therefore generate:

trait Iterator<Item> {}

fn f<I, J, Item>(x: Item) -> Item
where
    I: Iterator<Item>,
    J: Iterator<Item>,
{ x }
@Nadrieril Nadrieril self-assigned this Apr 16, 2024
@sonmarcho
Copy link
Member

Rephrasing a bit: we can extract the code above with Charon, and it's actually handled by Aeneas (which has a normalization mechanism) but the generated pure model doesn't type-check.

@Nadrieril Nadrieril added the C-unsupported-language-feature A rust feature we don't extract well label Apr 23, 2024
@Nadrieril Nadrieril removed their assignment Apr 26, 2024
@Nadrieril Nadrieril added C-simplification-pass Request for charon to process the output llbc and removed C-unsupported-language-feature A rust feature we don't extract well labels May 14, 2024
@Nadrieril Nadrieril changed the title Support associated types equality constraints Hide associated types equality constraints May 14, 2024
@Nadrieril Nadrieril self-assigned this May 14, 2024
@Nadrieril
Copy link
Member Author

Copying over the current limitation I wrote about in #532:

This has 4 know limitations today:

This also has 3 fundamental limitations that we can't work around:

  • We can't handle GATs, as this would require passing type-level functions as type parameters;
  • We can't handle for<'a> clauses with unconstrained associated types, for the same reason;
  • We can't add parameters to self-recursive traits, as this would require an infinite list of parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-simplification-pass Request for charon to process the output llbc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants