-
Notifications
You must be signed in to change notification settings - Fork 17
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
Use DeBruijn indices for all type-level variables #361
Comments
Here's the current plan, from discussions with @sonmarcho:
To link between methods and their trait/impl container, we do the following: trait Trait<T> {
fn method<U>();
}
impl<T> Trait<Foo<T>> for Bar<T> {
fn method<U>() {}
}
// represented as:
fn impl#0::method<T, U>() {}
impl<T> Trait<Foo<T>> for Bar<T> {
fn method = for<U> impl#0::method<T, U>
} In other words, the method is translated to an ordinary freestanding function. The only way it knows it's a method is via This makes it possible to alter the generics of items locally without needing to split and merge lists of generics in error-prone ways. This is particularly important for #127. This does mean that to go from an impl to one of its methods, we need to do a bit of substitution. The other places where we introduce new binder levels are GATs and |
A few features involve nested binders:
for<'a>
clauses and function pointer types;dyn Trait
, which I would like to encode asexists<T> T: Trait<Vars..>
;Today we use binder groups + DeBruijn indices (just like rustc) for lifetime parameters. To support all these features cleanly I would like to do the same for type, const and trait clause parameters.
The text was updated successfully, but these errors were encountered: