Uh oh!
There was an error while loading. Please reload this page.
move closure kind, signature into ClosureSubsts - #45879
Conversation
nikomatsakis
commented
Nov 8, 2017
cc @Mark-Simulacrum -- potential breaking change |
There was a problem hiding this comment.
Don't you want to do this change for generators too? Generators referencing themselves are just as bad as closures doing so.
There was a problem hiding this comment.
Yes, but for purposes of getting crater results, not really needed. Will do, however.
nikomatsakis
commented
Nov 9, 2017
Hmm, the mir-opt tests seem... maybe real? Will have to investigate later. |
nikomatsakis
commented
Nov 9, 2017
The mir-opt problem turns out to be an existing bug in inlining. |
nikomatsakis
commented
Nov 10, 2017
So should we do a crater run here? In that case, do we want to do a try build? |
bors
commented
Nov 10, 2017
☔ The latest upstream changes (presumably #45785) made this pull request unmergeable. Please resolve the merge conflicts. |
3a1134d to
d5a54a9Comparenikomatsakis
commented
Nov 11, 2017
cc @rust-lang/infra -- what is the procedure for doing a crater run here? |
nikomatsakis
commented
Nov 11, 2017
@bors try |
bors
commented
Nov 11, 2017
[WIP] move closure kind, signature into `ClosureSubsts` Instead of using side-tables, store the closure-kind and signature in the substitutions themselves. This has two key effects: - It means that the closure's type changes as inference finds out more things, which is very nice. - As a result, it avoids the need for the `freshen_closure_like` code (though we still use it for generators). - It avoids cyclic closures calls. - These were never meant to be supported, precisely because they make a lot of the fancy inference that we do much more complicated. However, due to an oversight, it was previously possible -- if challenging -- to create a setup where a closure *directly* called itself (see e.g. #21410). We have to see what the effect of this change is, though. Needs a crater run. Marking as [WIP] until that has been assessed. r? @arielb1
bors
commented
Nov 11, 2017
☀️ Test successful - status-travis |
alexcrichton
commented
Nov 12, 2017
r? @arielb1 (assigning a reviewer) |
nikomatsakis
commented
Nov 13, 2017
Rebased. |
d5a54a9 to
0f6bd17CompareI also decided to start an "old school" crater run.
Root regressions, sorted by rank:
|
nikomatsakis
commented
Nov 13, 2017
@bors try |
bors
commented
Nov 13, 2017
[WIP] move closure kind, signature into `ClosureSubsts` Instead of using side-tables, store the closure-kind and signature in the substitutions themselves. This has two key effects: - It means that the closure's type changes as inference finds out more things, which is very nice. - As a result, it avoids the need for the `freshen_closure_like` code (though we still use it for generators). - It avoids cyclic closures calls. - These were never meant to be supported, precisely because they make a lot of the fancy inference that we do much more complicated. However, due to an oversight, it was previously possible -- if challenging -- to create a setup where a closure *directly* called itself (see e.g. #21410). We have to see what the effect of this change is, though. Needs a crater run. Marking as [WIP] until that has been assessed. r? @arielb1
bors
commented
Nov 13, 2017
☀️ Test successful - status-travis |
aidanhs
commented
Nov 14, 2017
@nikomatsakis just pinging rust-lang/infra and saying "requesting crater run" will (eventually) get a crater run done. |
nikomatsakis
commented
Nov 14, 2017
@aidanhs thanks =) |
nikomatsakis
commented
Nov 14, 2017
So, based on the "old school" crater results (no regressions), I see three paths forward:
I'm leaning mildly towards path 2, but we'll see how much time I get for it. I just prefer to give warnings if we can. |
| // not known to hold in the creator's context (and | ||
| // indeed the closure may not be invoked by its | ||
| // creator, but rather turned to someone who *can* | ||
| // verify that). |
There was a problem hiding this comment.
This also doesn't check captured variables from the parent function's generics.
Maybe these don't matter, because within a function the generics are always the function's own - and therefore WF, and outside of it a TyClosure should not appear in the wild. So I'll either add the generics in, or be sure they don't matter and add a comment..
| EntryKind::Generator(self.lazy(&data)) | ||
| } | ||
| ty::TyClosure(def_id, substs) => { |
There was a problem hiding this comment.
nit: isn't a closure's signature stored in the closure's item type? storing the data separately feels like it's only likely to cause mimsmatches and trouble (aka can't CrateMetadata::fn_sig call tcx.item_type(def_id).closure_sig(def_id, tcx)?)
There was a problem hiding this comment.
Does seem silly. Let me see if it can be readily purged.
There was a problem hiding this comment.
It's not really obvious to me how to do this. I'm sure it can be done, but I don't think that item_type will do it. I believe that gives back something with "identity" substitutions, which isn't really what we want here (i.e., the closure_sig parameter will be an unsubstituted type parameter). The other definition of fn_sig uses the typeck_tables to get what we want, but for that we need the HirId of the closure, and I'm not sure how to get that from another crate.
arielb1
commented
Nov 18, 2017
r=me mod. comments also, apparently MIR inlining is still somewhat broken with closures. I'll try to open an issue. |
arielb1
commented
Nov 18, 2017
this is #46086 |
36c7dc0 to
c490241Comparec490241 to
df6fdbcComparearielb1
commented
Nov 19, 2017
Test problem: |
arielb1
commented
Nov 19, 2017
r=me with test fixed. |
arielb1
commented
Nov 20, 2017
@bors r+ |
bors
commented
Nov 20, 2017
📌 Commit 9af5a06 has been approved by |
nikomatsakis
commented
Nov 20, 2017
@bors r=arielb1 |
bors
commented
Nov 20, 2017
📌 Commit b9c766c has been approved by |
Before we were assuming that *every* `fn_sig` must pertain to a local closure.
nikomatsakis
commented
Nov 21, 2017
@bors r=arielb1 |
bors
commented
Nov 21, 2017
📌 Commit 00732a3 has been approved by |
bors
commented
Nov 21, 2017
move closure kind, signature into `ClosureSubsts` Instead of using side-tables, store the closure-kind and signature in the substitutions themselves. This has two key effects: - It means that the closure's type changes as inference finds out more things, which is very nice. - As a result, it avoids the need for the `freshen_closure_like` code (though we still use it for generators). - It avoids cyclic closures calls. - These were never meant to be supported, precisely because they make a lot of the fancy inference that we do much more complicated. However, due to an oversight, it was previously possible -- if challenging -- to create a setup where a closure *directly* called itself (see e.g. #21410). We have to see what the effect of this change is, though. Needs a crater run. Marking as [WIP] until that has been assessed. r? @arielb1
bors
commented
Nov 22, 2017
☀️ Test successful - status-appveyor, status-travis |
Instead of using side-tables, store the closure-kind and signature in the substitutions themselves. This has two key effects:
freshen_closure_likecode (though we still use it for generators).We have to see what the effect of this change is, though. Needs a crater run. Marking as [WIP] until that has been assessed.
r? @arielb1