One possible approach for lazy normalization in rustc is as follows. One key observation here is that we can do lazy normalization for constants and for associated types independently. I'm going to lay out how things should work with constants, as they are mildly simpler – but associated types could follow along a similar path. (The major difference is that we must accommodate subtyping.)
ty::infer
code that does "subtyping", "type equality", and so forth:
(Unevaluated, _)
or (_, Unevaluated)
case, we generate an obligation instead of processing it immediately.super_relate_consts
code that does structural matching.ConstEquate(C, C)
– meaning that we have to prove the two constants equalConstEquate(C1, C2)
obligation can be handled as follows:
eval
each constant:
super_relate_consts
method on the (now normalized) sidessuper_relate_consts
is the same as today; it does structural matching on its two argumentsThe current handling of regions is something of an obstacle, as the leak_check
prevents us from creating obligations.
I am investigating removing it in the lazy-norm-anon-const-push-2 branch, but that re-opens some mildly tricky questions about the role the 'empty
region plays. In particular, as noted in this commit, a few notable tests start to
pass because of "empty" interactions that are not obviously desirable:
hrtb-exists-forall-trait-contravariant.rs
hrtb-exists-forall-trait-covariant.rs
issue-46989.rs
In addition, the following changes didn't seem obviously desired:
old-lub-glb-object.rs
got an additional errorissue-57639.rs
regresses, for the reasons covered in the issueFinally there are some anticipated regressions:
coherence-subtyping.rs
gets an additional errorAt heart is the question of whether this ought to be satisfiable:
exists<'a> { forall<'b> { 'b: 'a } }
The current region solver assumes ReEmpty
is less than all other things, which is the root of our problem here. I am exploring making ReEmpty
be indexed by a universe to get rid of this behavior. (Update: it looks like this is working.)
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing