Refactor ty::FnSig to contain a &'tcx Slice<Ty<'tcx>>#38097
Refactor ty::FnSig to contain a &'tcx Slice<Ty<'tcx>>#38097bors merged 2 commits intorust-lang:masterfrom
Conversation
src/librustc/ty/relate.rs
Outdated
src/librustc/ty/structural_impls.rs
Outdated
There was a problem hiding this comment.
I think you can just fold the list wholesale.
src/librustc/ty/sty.rs
Outdated
src/librustc/ty/sty.rs
Outdated
There was a problem hiding this comment.
You could keep this returning a slice.
src/librustc_trans/callee.rs
Outdated
There was a problem hiding this comment.
You're using iter::once a bit too much - try arrays instead.
src/librustc_trans/common.rs
Outdated
There was a problem hiding this comment.
Could you avoid .into_iter() on slices? It's just .iter().
src/librustc_typeck/astconv.rs
Outdated
There was a problem hiding this comment.
Why would this be needed? Looks like a bug?
There was a problem hiding this comment.
TypeFoldable isn't implemented for &[Ty<'tcx>], which is what we have, so we need to cast it to a vector in order to pass it here. This is rather unfortunate, but I'm not sure how much we can do. It may be worth pointing out that the use is a visit_with on it, so it's possible this can be refactored into passing either the slice or an iterator to solve this problem. I can look into that if you'd like.
6aee99f to
692dd7c
Compare
|
What is purpose of this? |
6bed7f6 to
c0d3460
Compare
|
I believe there are a couple of purposes:
@eddyb may be able to suggest other reasons. @eddyb Ready for another review pass. |
|
☔ The latest upstream changes (presumably #38053) made this pull request unmergeable. Please resolve the merge conflicts. |
c0d3460 to
5a30bf0
Compare
|
Rebased. |
src/librustc_typeck/lib.rs
Outdated
There was a problem hiding this comment.
Could you use slice iterators, here and elsewhere?
|
@Mark-Simulacrum Can you move the contents of that comment into the description? You may also want to mention that the drop glue thing is about arenas, both in terms of cost of dropping/reusing the temporary ones currently and experiments with unified arenas in the future. |
|
@rust-lang/compiler Any objections? This is ready to land otherwise, modulo a few "style" tweaks. |
5a30bf0 to
2114a4b
Compare
|
Fixed style nit (I couldn't find any other places I chained iter::once together). Added the comment for reasons why we want this to the description. |
|
☔ The latest upstream changes (presumably #38121) made this pull request unmergeable. Please resolve the merge conflicts. |
2114a4b to
296ec5f
Compare
|
Rebased. |
|
@bors r+ |
|
📌 Commit 296ec5f has been approved by |
Refactor ty::FnSig to contain a &'tcx Slice<Ty<'tcx>> We refactor this in order to achieve the following wins: - Decrease the size of `FnSig` (`Vec` + `bool`: 32, `&Slice` + `bool`: 24). - Potentially decrease total allocated memory due to arena-allocating `FnSig` inputs/output; since they are allocated in the type list arena, other users of type lists can reuse the same allocation for an equivalent type list. - Remove the last part of the type system which needs drop glue (#37965 removed the other remaining part). This makes arenas containing `FnSig` faster to drop (since we don't need to drop a Vec for each one), and makes reusing them without clearing/dropping potentially possible. r? @eddyb
|
Nice! |
We refactor this in order to achieve the following wins:
FnSig(Vec+bool: 32,&Slice+bool: 24).FnSiginputs/output; since they are allocated in the type list arena, other users of type lists can reuse the same allocation for an equivalent type list.FnSigfaster to drop (since we don't need to drop a Vec for each one), and makes reusing them without clearing/dropping potentially possible.r? @eddyb