Description
#62429 manually deduplicated monomorphizations of closures. We should automate this during building instead of requiring users to do it manually. Ideally we'll revert the parts of #62429 that made things less readable as the last step of closing this issue.
I think the endgame would be that we'd deduplicate closures (in release mode only, so backtraces's file:line locations still make sense in debug mode), as long as their body is the same.
Not sure if that is possible, but random idea:
If we only care about monomorphizations in llvm, we could create a function that takes a closure's mir::Body
, cleans it of all "unnecessary" info like Span
s and then feeds that through a query (which thus will only be called once with the same arguments), producing the appropriate codegen backend's function handle.
If we want to reduce type lengths, too, we'd need to change the way closure substs are built, by computing the minimal required set ahead of time.