Auto merge of #50395 - Zoxc:small-tys, r=michaelwoerister
Optimize layout of TypeVariants This makes references to `Slice` use thin pointers by storing the slice length in the slice itself. `GeneratorInterior` is replaced by storing the movability of generators in `TyGenerator` and the interior witness is stored in `GeneratorSubsts` (which is just a wrapper around `&'tcx Substs`, like `ClosureSubsts`). Finally the fields of `TypeAndMut` is stored inline in `TyRef`. These changes combine to reduce `TypeVariants` from 48 bytes to 24 bytes on x86_64. r? @michaelwoerister
This commit is contained in:
commit
0a223d139c
84 changed files with 615 additions and 537 deletions
|
@ -1480,7 +1480,7 @@ impl<'a, 'tcx> Clean<TyParamBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>
|
|||
for ty_s in trait_ref.input_types().skip(1) {
|
||||
if let ty::TyTuple(ts) = ty_s.sty {
|
||||
for &ty_s in ts {
|
||||
if let ty::TyRef(ref reg, _) = ty_s.sty {
|
||||
if let ty::TyRef(ref reg, _, _) = ty_s.sty {
|
||||
if let &ty::RegionKind::ReLateBound(..) = *reg {
|
||||
debug!(" hit an ReLateBound {:?}", reg);
|
||||
if let Some(lt) = reg.clean(cx) {
|
||||
|
@ -2231,8 +2231,8 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
|
|||
let self_arg_ty = *sig.input(0).skip_binder();
|
||||
if self_arg_ty == self_ty {
|
||||
decl.inputs.values[0].type_ = Generic(String::from("Self"));
|
||||
} else if let ty::TyRef(_, mt) = self_arg_ty.sty {
|
||||
if mt.ty == self_ty {
|
||||
} else if let ty::TyRef(_, ty, _) = self_arg_ty.sty {
|
||||
if ty == self_ty {
|
||||
match decl.inputs.values[0].type_ {
|
||||
BorrowedRef{ref mut type_, ..} => {
|
||||
**type_ = Generic(String::from("Self"))
|
||||
|
@ -2786,10 +2786,10 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
|||
Array(box ty.clean(cx), n)
|
||||
}
|
||||
ty::TyRawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)),
|
||||
ty::TyRef(r, mt) => BorrowedRef {
|
||||
ty::TyRef(r, ty, mutbl) => BorrowedRef {
|
||||
lifetime: r.clean(cx),
|
||||
mutability: mt.mutbl.clean(cx),
|
||||
type_: box mt.ty.clean(cx),
|
||||
mutability: mutbl.clean(cx),
|
||||
type_: box ty.clean(cx),
|
||||
},
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(_) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue