Auto merge of #93505 - lcnr:substsref-vs-ty-list, r=michaelwoerister
safely `transmute<&List<Ty<'tcx>>, &List<GenericArg<'tcx>>>` This PR has 3 relevant steps which are is split in distinct commits. The first commit now interns `List<Ty<'tcx>>` and `List<GenericArg<'tcx>>` together, potentially reusing memory while allowing free conversions between these two using `List<Ty<'tcx>>::as_substs()` and `SubstsRef<'tcx>::try_as_type_list()`. Using this, we then use `&'tcx List<Ty<'tcx>>` instead of a `SubstsRef<'tcx>` for tuple fields, simplifying a bunch of code. Finally, as tuple fields and other generic arguments now use a different `TypeFoldable<'tcx>` impl, we optimize the impl for `List<Ty<'tcx>>` improving perf by slightly less than 1% in tuple heavy benchmarks.
This commit is contained in:
commit
03a8cc7df1
64 changed files with 289 additions and 210 deletions
|
@ -256,7 +256,7 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
|
|||
// We must have inferred the capture types since we are building MIR, therefore
|
||||
// it's safe to call `tuple_element_ty` and we can unwrap here because
|
||||
// we know that the capture exists and is the `capture_index`-th capture.
|
||||
let var_ty = substs.tupled_upvars_ty().tuple_element_ty(capture_index).unwrap();
|
||||
let var_ty = substs.tupled_upvars_ty().tuple_fields()[capture_index];
|
||||
|
||||
upvar_resolved_place_builder =
|
||||
upvar_resolved_place_builder.field(Field::new(capture_index), var_ty);
|
||||
|
|
|
@ -1209,7 +1209,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
|
|||
) -> Self {
|
||||
let ret = match constructor {
|
||||
Single | Variant(_) => match ty.kind() {
|
||||
ty::Tuple(fs) => Fields::wildcards_from_tys(cx, fs.iter().map(|ty| ty.expect_ty())),
|
||||
ty::Tuple(fs) => Fields::wildcards_from_tys(cx, fs.iter()),
|
||||
ty::Ref(_, rty, _) => Fields::wildcards_from_tys(cx, once(*rty)),
|
||||
ty::Adt(adt, substs) => {
|
||||
if adt.is_box() {
|
||||
|
@ -1315,11 +1315,8 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
|||
match pat.ty.kind() {
|
||||
ty::Tuple(fs) => {
|
||||
ctor = Single;
|
||||
let mut wilds: SmallVec<[_; 2]> = fs
|
||||
.iter()
|
||||
.map(|ty| ty.expect_ty())
|
||||
.map(DeconstructedPat::wildcard)
|
||||
.collect();
|
||||
let mut wilds: SmallVec<[_; 2]> =
|
||||
fs.iter().map(DeconstructedPat::wildcard).collect();
|
||||
for pat in subpatterns {
|
||||
wilds[pat.field.index()] = mkpat(&pat.pattern);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue