-
Notifications
You must be signed in to change notification settings - Fork 0
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
lazy norm, infinitely sized types, and the occurs check #133
Comments
cc https://hackmd.io/N0rzMn94QZOfbaAVOl4f6A#finite-size-is-good-actually one solution would be to attempt to eagerly detect associated type definitions which may expand to infinite types. This is already allowed on stable and would therefore require a breaking change. One such example is the following: trait Trait {
type Assoc;
}
impl<T: Trait> Trait for Vec<T> {
type Assoc = T::Assoc;
}
trait Indir {
type IndirAssoc<T: Trait>: Trait;
}
struct Map<T>(T);
impl<T: Indir> Trait for Map<T> {
type Assoc = <T::IndirAssoc<Self> as Trait>::Assoc;
}
// in a downstream crate
struct Local;
impl Indir for Local {
type IndirAssoc<T: Trait> = Vec<T>;
}
// `<Map<Local> as Trait>::Assoc` is now infinite,
// all impls are
// fine by itself. |
Conclusion: we are going to ignore this for now. We don't know of a concrete problem. We do know of various solutions (noted below) all of which seem unappealing but also largely orthogonal to other issues we have to address so we prefer to ignore this problem for now. Options include:
|
for
type Alias = Vec<Alias>;
, equatingAlias
withVec<Alias>
may succeed:normalizes-to(Alias, Vec<Alias>) -> Vec<Alias>
equate(Vec<Alias>, Vec<Alias>)
ok via structural equality fast-pathThis would cause the occurs check to be incomplete as
?0 eq Vec<?0>
can be proven by instantiating?0
withAlias
. The occurs check is strictly required:This issue is pretty much purely theoretical as we're eagerly replacing all aliases inside of the normalized type with infer vars when equating it with the expected term. I don't necessarily believe we need to handle this until somebody crafts an example where this causes 'overlap' of impls allowed due to the occurs check.
The text was updated successfully, but these errors were encountered: